| 1 | <?php |
||
| 8 | trait HasTools |
||
| 9 | { |
||
| 10 | use HasSearchBar; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Header tools. |
||
| 14 | * |
||
| 15 | * @var Tools |
||
| 16 | */ |
||
| 17 | public $tools; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Setup grid tools. |
||
| 21 | * |
||
| 22 | * @return $this |
||
| 23 | */ |
||
| 24 | protected function initTools() |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Disable header tools. |
||
| 33 | * |
||
| 34 | * @return $this |
||
| 35 | */ |
||
| 36 | public function disableTools(bool $disable = true) |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Setup grid tools. |
||
| 43 | * |
||
| 44 | * @param Closure $callback |
||
| 45 | * |
||
| 46 | * @return void |
||
| 47 | */ |
||
| 48 | public function tools(Closure $callback) |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Render custom tools. |
||
| 55 | * |
||
| 56 | * @return string |
||
| 57 | */ |
||
| 58 | public function renderHeaderTools() |
||
| 62 | |||
| 63 | /** |
||
| 64 | * If grid show header tools. |
||
| 65 | * |
||
| 66 | * @return bool |
||
| 67 | */ |
||
| 68 | public function showTools() |
||
| 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.