1 | <?php |
||
10 | trait HasData |
||
11 | { |
||
12 | /** |
||
13 | * @var string|array |
||
14 | */ |
||
15 | protected $ajax = ''; |
||
16 | |||
17 | /** |
||
18 | * Setup ajax parameter. |
||
19 | * |
||
20 | * @param string|array $attributes |
||
21 | * @return $this |
||
22 | */ |
||
23 | public function ajax($attributes = '') |
||
29 | |||
30 | /** |
||
31 | * Setup "ajax" parameter with POST method. |
||
32 | * |
||
33 | * @param string|array $attributes |
||
34 | * @return $this |
||
35 | */ |
||
36 | public function postAjax($attributes = '') |
||
48 | |||
49 | /** |
||
50 | * Setup ajax parameter for datatables pipeline plugin. |
||
51 | * |
||
52 | * @param string $url |
||
53 | * @param string $pages |
||
54 | * @return $this |
||
55 | */ |
||
56 | public function pipeline($url, $pages) |
||
62 | |||
63 | /** |
||
64 | * Minify ajax url generated when using get request |
||
65 | * by deleting unnecessary url params. |
||
66 | * |
||
67 | * @param string $url |
||
68 | * @param string $script |
||
69 | * @param array $data |
||
70 | * @param array $ajaxParameters |
||
71 | * @return $this |
||
72 | */ |
||
73 | public function minifiedAjax($url = '', $script = null, $data = [], $ajaxParameters = []) |
||
107 | |||
108 | /** |
||
109 | * Get ajax url. |
||
110 | * |
||
111 | * @return array|mixed|string |
||
112 | */ |
||
113 | public function getAjaxUrl() |
||
121 | |||
122 | /** |
||
123 | * Set ajax url with data added from form. |
||
124 | * |
||
125 | * @param string $url |
||
126 | * @param string $formSelector |
||
127 | * @return $this |
||
128 | */ |
||
129 | public function ajaxWithForm($url, $formSelector) |
||
140 | } |
||
141 |
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.