diff --git a/src/Abstracts/Carrier.php b/src/Abstracts/Carrier.php index b4763ec06..1ab74d118 100644 --- a/src/Abstracts/Carrier.php +++ b/src/Abstracts/Carrier.php @@ -119,7 +119,7 @@ public function __construct($slug = null, $name = null) ] ); - $nonceField->section = 'notification_carrier_' . $this->getSlug(); + $nonceField->setSection('notification_carrier_' . $this->getSlug()); $this->formFields[$nonceField->getRawName()] = $nonceField; @@ -135,7 +135,7 @@ public function __construct($slug = null, $name = null) ] ); - $activatedField->section = 'notification_carrier_' . $this->getSlug(); + $activatedField->setSection('notification_carrier_' . $this->getSlug()); $this->formFields[$activatedField->getRawName()] = $activatedField; @@ -151,7 +151,7 @@ public function __construct($slug = null, $name = null) ] ); - $enabledField->section = 'notification_carrier_' . $this->getSlug(); + $enabledField->setSection('notification_carrier_' . $this->getSlug()); $this->formFields[$enabledField->getRawName()] = $enabledField; @@ -215,12 +215,12 @@ public function hash() /** * Adds form field to collection * - * @param \BracketSpace\Notification\Abstracts\Field $field Field object. + * @param \BracketSpace\Notification\Interfaces\Fillable $field Field object. * @return $this * @throws \Exception When restricted name is used. * @since 6.0.0 Added restricted field check. */ - public function addFormField(\BracketSpace\Notification\Abstracts\Field $field) + public function addFormField(Interfaces\Fillable $field) { if ( @@ -239,7 +239,7 @@ public function addFormField(\BracketSpace\Notification\Abstracts\Field $field) } $addingField = clone $field; - $addingField->section = 'notification_carrier_' . $this->getSlug(); + $addingField->setSection('notification_carrier_' . $this->getSlug()); $this->formFields[$field->getRawName()] = $addingField; diff --git a/src/Abstracts/Field.php b/src/Abstracts/Field.php index 2866dd8a3..ddbbf9d0a 100644 --- a/src/Abstracts/Field.php +++ b/src/Abstracts/Field.php @@ -69,7 +69,7 @@ abstract class Field implements Interfaces\Fillable * * @var string */ - public $section = ''; + protected $section = ''; /** * If field is disabled @@ -222,6 +222,27 @@ public function setValue($value) $this->value = $value; } + /** + * Gets field section name + * + * @return string + */ + public function getSection() + { + return $this->section; + } + + /** + * Sets field section name + * + * @param string $value assigned value + * @return void + */ + public function setSection($value) + { + $this->section = $value; + } + /** * Gets field name * @@ -229,7 +250,7 @@ public function setValue($value) */ public function getName() { - return $this->section . '[' . $this->name . ']'; + return $this->getSection() . '[' . $this->name . ']'; } /** diff --git a/src/Interfaces/Fillable.php b/src/Interfaces/Fillable.php index 3b7afb7e7..86d38f029 100644 --- a/src/Interfaces/Fillable.php +++ b/src/Interfaces/Fillable.php @@ -10,11 +10,6 @@ namespace BracketSpace\Notification\Interfaces; -/** - * Fillable interface - * - * @property string $section Field section name. - */ interface Fillable { /** @@ -32,6 +27,21 @@ public function getValue(); */ public function setValue($value); + /** + * Gets field section name + * + * @return string + */ + public function getSection(); + + /** + * Sets field section name + * + * @param string $value assigned value + * @return void + */ + public function setSection($value); + /** * Gets field name *