| 1 | <?php |
||
| 8 | trait HasTools |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * Header tools. |
||
| 12 | * |
||
| 13 | * @var Tools |
||
| 14 | */ |
||
| 15 | public $tools; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Setup grid tools. |
||
| 19 | */ |
||
| 20 | public function setupTools() |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Disable header tools. |
||
| 27 | * |
||
| 28 | * @return $this |
||
| 29 | */ |
||
| 30 | public function disableTools(bool $disable = true) |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Setup grid tools. |
||
| 37 | * |
||
| 38 | * @param Closure $callback |
||
| 39 | * |
||
| 40 | * @return void |
||
| 41 | */ |
||
| 42 | public function tools(Closure $callback) |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Render custom tools. |
||
| 49 | * |
||
| 50 | * @return string |
||
| 51 | */ |
||
| 52 | public function renderHeaderTools() |
||
| 56 | |||
| 57 | /** |
||
| 58 | * If grid show header tools. |
||
| 59 | * |
||
| 60 | * @return bool |
||
| 61 | */ |
||
| 62 | public function showTools() |
||
| 66 | } |
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.