1 | <?php |
||
10 | trait CanExportGrid |
||
11 | { |
||
12 | /** |
||
13 | * Export driver. |
||
14 | * |
||
15 | * @var string |
||
16 | */ |
||
17 | protected $exporter; |
||
18 | |||
19 | /** |
||
20 | * Handle export request. |
||
21 | * |
||
22 | * @param bool $forceExport |
||
23 | */ |
||
24 | protected function handleExportRequest($forceExport = false) |
||
41 | |||
42 | /** |
||
43 | * @param string $scope |
||
44 | * |
||
45 | * @return AbstractExporter |
||
46 | */ |
||
47 | protected function getExporter($scope) |
||
51 | |||
52 | /** |
||
53 | * Set exporter driver for Grid to export. |
||
54 | * |
||
55 | * @param $exporter |
||
56 | * |
||
57 | * @return $this |
||
58 | */ |
||
59 | public function exporter($exporter) |
||
65 | |||
66 | /** |
||
67 | * Get the export url. |
||
68 | * |
||
69 | * @param int $scope |
||
70 | * @param null $args |
||
71 | * |
||
72 | * @return string |
||
73 | */ |
||
74 | public function getExportUrl($scope = 1, $args = null) |
||
84 | |||
85 | /** |
||
86 | * If grid show export btn. |
||
87 | * |
||
88 | * @return bool |
||
89 | */ |
||
90 | public function showExportBtn() |
||
94 | |||
95 | /** |
||
96 | * Disable export. |
||
97 | * |
||
98 | * @return $this |
||
99 | */ |
||
100 | public function disableExport(bool $disable = true) |
||
104 | |||
105 | /** |
||
106 | * Render export button. |
||
107 | * |
||
108 | * @return string |
||
109 | */ |
||
110 | public function renderExportButton() |
||
114 | |||
115 | /** |
||
116 | * @param \Closure $callback |
||
117 | */ |
||
118 | public function export(\Closure $callback) |
||
128 | } |
||
129 |
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
Idable
provides a methodequalsId
that 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.