| 1 |
<?php |
| 2 |
|
| 3 |
namespace SimpleAnalytics\Settings\Concerns; |
| 4 |
|
| 5 |
use SimpleAnalytics\Settings\Block; |
| 6 |
use SimpleAnalytics\Settings\Blocks\CalloutBlock; |
| 7 |
use SimpleAnalytics\Settings\Blocks\Fields\Checkbox; |
| 8 |
use SimpleAnalytics\Settings\Blocks\Fields\Checkboxes; |
| 9 |
use SimpleAnalytics\Settings\Blocks\Fields\Input; |
| 10 |
use SimpleAnalytics\Settings\Blocks\Fields\IpList; |
| 11 |
|
| 12 |
trait ManagesBlocks |
| 13 |
{ |
| 14 |
abstract protected function addBlock(Block $block): self; |
| 15 |
|
| 16 |
public function callout(string $text): CalloutBlock |
| 17 |
{ |
| 18 |
$block = new CalloutBlock($text); |
| 19 |
$this->addBlock($block); |
| 20 |
return $block; |
| 21 |
} |
| 22 |
|
| 23 |
public function input(string $key, string $label): Input |
| 24 |
{ |
| 25 |
$field = new Input($key, $label); |
| 26 |
$this->addBlock($field); |
| 27 |
return $field; |
| 28 |
} |
| 29 |
|
| 30 |
public function checkbox(string $key, string $label): Checkbox |
| 31 |
{ |
| 32 |
$field = new Checkbox($key, $label); |
| 33 |
$this->addBlock($field); |
| 34 |
return $field; |
| 35 |
} |
| 36 |
|
| 37 |
public function multiCheckbox(string $key, string $label): Checkboxes |
| 38 |
{ |
| 39 |
$field = new Checkboxes($key, $label); |
| 40 |
$this->addBlock($field); |
| 41 |
return $field; |
| 42 |
} |
| 43 |
|
| 44 |
public function ipList(string $key, string $label): IpList |
| 45 |
{ |
| 46 |
$field = new IpList($key, $label); |
| 47 |
$this->addBlock($field); |
| 48 |
return $field; |
| 49 |
} |
| 50 |
} |
| 51 |
|