1 | <?php defined('SYSPATH') OR die('No direct access allowed.'); |
||
19 | class Kohana_Jam_Behavior_Sluggable extends Jam_Behavior { |
||
20 | |||
21 | const SLUG = "/^[a-z0-9-]+$/"; |
||
22 | const ID_SLUG = "/^([a-z0-9-]+?-)?([1-9][0-9]*)$/"; |
||
23 | |||
24 | protected $_slug = NULL; |
||
25 | |||
26 | protected $_pattern = NULL; |
||
27 | |||
28 | protected $_uses_primary_key = TRUE; |
||
29 | |||
30 | protected $_auto_save = TRUE; |
||
31 | |||
32 | protected $_unique = TRUE; |
||
33 | |||
34 | /** |
||
35 | * Initializes the behavior |
||
36 | * |
||
37 | * It sets the fields used in generating the slug |
||
38 | * |
||
39 | * @param Jam_Event $event the jam event for the behavior |
||
|
|||
40 | * @param Jam_Model $model The Jam_Model object on which the behavior is applies |
||
41 | * @param string $name |
||
42 | * @return void |
||
43 | */ |
||
44 | public function initialize(Jam_Meta $meta, $name) |
||
65 | |||
66 | /** |
||
67 | * Getter for parameter |
||
68 | * @return bool |
||
69 | */ |
||
70 | 11 | public function auto_save() |
|
74 | |||
75 | /** |
||
76 | * Getter for parameter |
||
77 | * @return bool |
||
78 | */ |
||
79 | public function unique() |
||
83 | |||
84 | /** |
||
85 | * Getter for parameter |
||
86 | * @return bool |
||
87 | */ |
||
88 | 11 | public function uses_primary_key() |
|
92 | |||
93 | /** |
||
94 | * Getter for parameter |
||
95 | * @return bool |
||
96 | */ |
||
97 | public function pattern() |
||
101 | |||
102 | /** |
||
103 | * Getter for parameter |
||
104 | * @return bool |
||
105 | */ |
||
106 | public function slug() |
||
110 | |||
111 | /** |
||
112 | * Called before validation. |
||
113 | * If the slug does not use the primary key the slug is built event before |
||
114 | * the validation. This way it could be validated and there are no |
||
115 | * additional database queries to update it. |
||
116 | * |
||
117 | * @param Jam_Model $model |
||
118 | */ |
||
119 | 12 | public function model_before_check(Jam_Model $model) |
|
127 | |||
128 | /** |
||
129 | * Called after save. |
||
130 | * If the slug uses the primary key it is built after save and it is updated |
||
131 | * with an additional database query. |
||
132 | * |
||
133 | * @param Jam_Model $model |
||
134 | */ |
||
135 | 13 | public function model_after_save(Jam_Model $model) |
|
151 | |||
152 | 10 | static public function _uses_primary_key_pattern(Jam_Model $model) |
|
156 | |||
157 | static public function _no_primary_key_pattern(Jam_Model $model) |
||
161 | |||
162 | /** |
||
163 | * Generates the slug for a model object |
||
164 | * @param Jam_Model $model the Jam_Model object |
||
165 | * @return string the generated slug |
||
166 | * @uses URL::title to strip obsolete characters and build the slug |
||
167 | */ |
||
168 | 13 | public function model_call_build_slug(Jam_Model $model, Jam_Event_Data $data) |
|
177 | |||
178 | |||
179 | /** |
||
180 | * Generated a find_by_slug method for Jam_Builder |
||
181 | * @param Jam_Builder $builder the builder object |
||
182 | * @param string $slug the slug to search for |
||
183 | * @param Jam_Event_Data $data |
||
184 | * @return void |
||
185 | */ |
||
186 | 16 | public function builder_call_where_slug(Jam_Query_Builder_Select $builder, Jam_Event_Data $data, $slug) |
|
197 | |||
198 | /** |
||
199 | * Generated a find_by_slug method for Jam_Builder |
||
200 | * @param Jam_Builder $builder the builder object |
||
201 | * @param string $slug the slug to search for |
||
202 | * @param Jam_Event_Data $data |
||
203 | * @return void |
||
204 | */ |
||
205 | 5 | public function builder_call_find_by_slug(Jam_Query_Builder_Select $builder, Jam_Event_Data $data, $slug) |
|
212 | |||
213 | /** |
||
214 | * Generates a find_by_slug_insist method for Jam_Builder |
||
215 | * @param Jam_Builder $builder the builder object |
||
216 | * @param string $slug the slug to search for |
||
217 | * @param Jam_Event_Data $data |
||
218 | * @return void |
||
219 | */ |
||
220 | 2 | public function builder_call_find_by_slug_insist(Jam_Query_Builder_Select $builder, Jam_Event_Data $data, $slug) |
|
230 | |||
231 | 8 | public function model_call_matches_slug(Jam_Model $model, Jam_Event_Data $data, $slug) |
|
235 | |||
236 | 3 | public function model_call_matches_slug_insist(Jam_Model $model, Jam_Event_Data $data, $slug) |
|
243 | } // End Jam_Behavior_Sluggable |
||
244 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.