| 1 | <?php |
||
| 12 | trait Field |
||
| 13 | {
|
||
| 14 | /** |
||
| 15 | * The name of the field.To prevent the field from being included in the form submit, set submitValue to false. |
||
| 16 | * @param $name |
||
| 17 | * @return mixed |
||
| 18 | */ |
||
| 19 | public function setName($name){
|
||
| 22 | |||
| 23 | public function getName(){
|
||
| 26 | |||
| 27 | |||
| 28 | |||
| 29 | /** |
||
| 30 | * Setting this to false will prevent the field from being submitted even when it is not disabled. |
||
| 31 | * @param bool $submitValue |
||
| 32 | * @return mixed |
||
| 33 | */ |
||
| 34 | public function setSubmitValue($submitValue){
|
||
| 37 | |||
| 38 | public function getSubmitValue(){
|
||
| 41 | |||
| 42 | |||
| 43 | |||
| 44 | /** |
||
| 45 | * True to disable the field. Disabled Fields will not be submitted. |
||
| 46 | * @param $disabled |
||
| 47 | * @return mixed |
||
| 48 | */ |
||
| 49 | public function setDisabled($disabled){
|
||
| 52 | |||
| 53 | public function getDisabled(){
|
||
| 56 | |||
| 57 | |||
| 58 | |||
| 59 | /** |
||
| 60 | * A value to initialize this field with. |
||
| 61 | * @param $value |
||
| 62 | * @return mixed |
||
| 63 | */ |
||
| 64 | public function setValue($value){
|
||
| 67 | |||
| 68 | public function getValue(){
|
||
| 71 | |||
| 72 | |||
| 73 | } |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idableprovides a methodequalsIdthat in turn relies on the methodgetId(). If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()as an abstract method to the trait will make sure it is available.