| Total Complexity | 8 |
| Total Lines | 54 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | trait CanInitializeTrait |
||
| 12 | { |
||
| 13 | |||
| 14 | /** |
||
| 15 | * Is the form prepared ? |
||
| 16 | * |
||
| 17 | * @var bool |
||
| 18 | */ |
||
| 19 | protected $initialized = false; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @deprecated use initialize() |
||
| 23 | */ |
||
| 24 | public function init() |
||
| 25 | { |
||
| 26 | return $this->initialize(); |
||
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @return $this |
||
| 31 | */ |
||
| 32 | public function initialize() |
||
| 33 | { |
||
| 34 | if ($this->initialized()) { |
||
| 35 | return $this; |
||
| 36 | } |
||
| 37 | |||
| 38 | $this->initAction(); |
||
| 39 | $this->postInit(); |
||
| 40 | $this->initialized(true); |
||
| 41 | return $this; |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @param null $initialized |
||
|
|
|||
| 46 | * @return bool |
||
| 47 | */ |
||
| 48 | protected function initialized($initialized = null): bool |
||
| 49 | { |
||
| 50 | if (is_bool($initialized)) { |
||
| 51 | $this->initialized = $initialized; |
||
| 52 | } |
||
| 53 | return $this->initialized; |
||
| 54 | } |
||
| 55 | |||
| 56 | protected function initAction() |
||
| 60 | } |
||
| 61 | } |
||
| 62 | |||
| 63 | public function postInit() |
||
| 65 | } |
||
| 66 | } |