Add `TPatternFormField`
authorMatthias Schmidt <gravatronics@live.com>
Tue, 22 Dec 2020 13:00:27 +0000 (14:00 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Tue, 22 Dec 2020 13:00:27 +0000 (14:00 +0100)
wcfsetup/install/files/lib/system/form/builder/field/TPatternFormField.class.php [new file with mode: 0644]

diff --git a/wcfsetup/install/files/lib/system/form/builder/field/TPatternFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/TPatternFormField.class.php
new file mode 100644 (file)
index 0000000..a74fee4
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+namespace wcf\system\form\builder\field;
+
+/**
+ * Provides default implementations of `IPatternFormField` methods.
+ *
+ * @author      Matthias Schmidt
+ * @copyright   2001-2020 WoltLab GmbH
+ * @license     GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package     WoltLabSuite\Core\System\Form\Builder\Field
+ * @since       5.4
+ */
+trait TPatternFormField {
+       /** @var ?string */
+       protected $pattern;
+       
+       /**
+        * Returns the `pattern` attribute of the form field.
+        *
+        * If `null` is returned, no `pattern` attribute will be set.
+        */
+       public function getPattern(): ?string {
+               return $this->pattern;
+       }
+       
+       /**
+        * Sets the `pattern` attribute of the form field.
+        *
+        * If `null` is given, the attribute is unset.
+        */
+       public function pattern(?string $pattern): self {
+               $this->pattern = $pattern;
+               
+               return $this;
+       }
+}