| 1 |
<?php |
| 2 |
|
| 3 |
namespace ipl\Html\Contract; |
| 4 |
|
| 5 |
use ipl\Html\ValidHtml; |
| 6 |
|
| 7 |
/** |
| 8 |
* Representation of form element decorators |
| 9 |
* |
| 10 |
* @deprecated Use {@see FormElementDecoration} instead |
| 11 |
*/ |
| 12 |
interface FormElementDecorator extends ValidHtml |
| 13 |
{ |
| 14 |
/** |
| 15 |
* Decorate the given form element |
| 16 |
* |
| 17 |
* Decoration works by calling `prependWrapper()` on the form element, |
| 18 |
* passing a clone of the decorator. Hidden elements are to be ignored. |
| 19 |
* |
| 20 |
* **Reference implementation:** |
| 21 |
* |
| 22 |
* ```php |
| 23 |
* public function decorate(FormElement $formElement) |
| 24 |
* { |
| 25 |
* if ($formElement instanceof HiddenElement) { |
| 26 |
* return; |
| 27 |
* } |
| 28 |
* |
| 29 |
* $decorator = clone $this; |
| 30 |
* |
| 31 |
* // Wrapper logic can be overridden to adjust or propagate the decorator. |
| 32 |
* // So here we make sure that a yet unbound decorator is passed. |
| 33 |
* $formElement->prependWrapper($decorator); |
| 34 |
* |
| 35 |
* ... |
| 36 |
* } |
| 37 |
* ``` |
| 38 |
* |
| 39 |
* @param FormElement $formElement |
| 40 |
*/ |
| 41 |
public function decorate(FormElement $formElement); |
| 42 |
} |