bytic /
form
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Nip\Form\Buttons; |
||
| 4 | |||
| 5 | use Nip\Form\AbstractForm; |
||
| 6 | |||
| 7 | /** |
||
| 8 | * Class AbstractButton |
||
| 9 | * @package Nip\Form\Buttons |
||
| 10 | */ |
||
| 11 | abstract class AbstractButton |
||
| 12 | { |
||
| 13 | use \Nip\Form\Traits\HasClassTrait; |
||
| 14 | use \Nip\Form\Traits\HasAttributesTrait; |
||
| 15 | |||
| 16 | protected $_form; |
||
| 17 | protected $_uniqueID; |
||
| 18 | |||
| 19 | protected $_type = 'abstract'; |
||
| 20 | |||
| 21 | 2 | public function __construct($form) |
|
| 22 | { |
||
| 23 | 2 | $this->setForm($form); |
|
| 24 | 2 | $this->init(); |
|
| 25 | 2 | } |
|
| 26 | |||
| 27 | 2 | public function init() |
|
| 28 | { |
||
| 29 | 2 | $this->addClass('btn', 'btn-primary'); |
|
| 30 | 2 | } |
|
| 31 | |||
| 32 | public function setId($id) |
||
| 33 | { |
||
| 34 | $this->setAttrib('id', $id); |
||
| 35 | |||
| 36 | return $this; |
||
| 37 | } |
||
| 38 | |||
| 39 | public function getId() |
||
| 40 | { |
||
| 41 | return $this->getAttrib('id'); |
||
| 42 | } |
||
| 43 | |||
| 44 | 1 | public function setName($name) |
|
| 45 | { |
||
| 46 | 1 | $this->setAttrib('name', $name); |
|
| 47 | |||
| 48 | 1 | return $this; |
|
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @return string |
||
| 53 | */ |
||
| 54 | 1 | public function getName() |
|
| 55 | { |
||
| 56 | 1 | return $this->getAttrib('name'); |
|
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @param string $label |
||
| 61 | * @return $this |
||
| 62 | */ |
||
| 63 | 1 | public function setLabel($label) |
|
| 64 | { |
||
| 65 | 1 | $this->setAttrib('label', $label); |
|
| 66 | |||
| 67 | 1 | return $this; |
|
| 68 | } |
||
| 69 | |||
| 70 | /** |
||
| 71 | * @return string |
||
| 72 | */ |
||
| 73 | 1 | public function getLabel() |
|
| 74 | { |
||
| 75 | 1 | return $this->getAttrib('label'); |
|
| 76 | } |
||
| 77 | |||
| 78 | /** |
||
| 79 | * @param $value |
||
| 80 | * @return $this |
||
| 81 | */ |
||
| 82 | public function setValue($value) |
||
| 83 | { |
||
| 84 | $this->setAttrib('value', $value); |
||
| 85 | |||
| 86 | return $this; |
||
| 87 | } |
||
| 88 | |||
| 89 | /** |
||
| 90 | * @param string $requester |
||
| 91 | * @return string |
||
| 92 | */ |
||
| 93 | public function getValue($requester = 'abstract') |
||
|
0 ignored issues
–
show
|
|||
| 94 | { |
||
| 95 | return $this->getAttrib('value'); |
||
| 96 | } |
||
| 97 | |||
| 98 | /** |
||
| 99 | * @param $key |
||
| 100 | * @return bool |
||
| 101 | */ |
||
| 102 | public function delAttrib($key) |
||
| 103 | { |
||
| 104 | $key = (string) $key; |
||
| 105 | unset($this->_attribs[$key]); |
||
| 106 | |||
| 107 | return true; |
||
| 108 | } |
||
| 109 | |||
| 110 | public function render() |
||
| 111 | { |
||
| 112 | return $this->getRenderer()->render($this); |
||
| 113 | } |
||
| 114 | |||
| 115 | 1 | public function getRenderer() |
|
| 116 | { |
||
| 117 | 1 | return $this->getForm()->getRenderer()->getButtonRenderer($this); |
|
| 118 | } |
||
| 119 | |||
| 120 | /** |
||
| 121 | * @return AbstractForm |
||
| 122 | */ |
||
| 123 | 1 | public function getForm() |
|
| 124 | { |
||
| 125 | 1 | return $this->_form; |
|
| 126 | } |
||
| 127 | |||
| 128 | /** |
||
| 129 | * @param AbstractForm $form |
||
| 130 | * @return $this |
||
| 131 | */ |
||
| 132 | 2 | public function setForm(AbstractForm $form) |
|
| 133 | { |
||
| 134 | 2 | $this->_form = $form; |
|
| 135 | |||
| 136 | 2 | return $this; |
|
| 137 | } |
||
| 138 | |||
| 139 | /** |
||
| 140 | * @return string |
||
| 141 | */ |
||
| 142 | 2 | public function getType() |
|
| 143 | { |
||
| 144 | 2 | return $this->_type; |
|
| 145 | } |
||
| 146 | } |
||
| 147 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.