44use ArrayObject ;
55use Cake \Event \Event ;
66use Cake \ORM \Behavior ;
7- use Cake \Utility \Inflector ;
87use Cake \Utility \Text ;
98use RuntimeException ;
109
@@ -33,15 +32,15 @@ class TagBehavior extends Behavior
3332 'className ' => 'Muffin/Tags.Tagged ' ,
3433 ],
3534 'taggedCounter ' => ['tag_count ' => [
36- 'conditions ' => []
35+ 'conditions ' => [],
3736 ]],
3837 'implementedEvents ' => [
3938 'Model.beforeMarshal ' => 'beforeMarshal ' ,
4039 ],
4140 'implementedMethods ' => [
4241 'normalizeTags ' => 'normalizeTags ' ,
4342 ],
44- 'fkTableField ' => 'fk_table '
43+ 'fkTableField ' => 'fk_table ' ,
4544 ];
4645
4746 /**
@@ -114,10 +113,10 @@ public function bindAssociations()
114113 if (!$ table ->hasAssociation ($ tagsAlias )) {
115114 $ table ->belongsToMany ($ tagsAlias , $ tagsAssoc + [
116115 'through ' => $ table ->{$ taggedAlias }->getTarget (),
117- 'conditions ' => $ assocConditions
116+ 'conditions ' => $ assocConditions,
118117 ]);
119118 }
120-
119+
121120 if (!$ table ->{$ tagsAlias }->hasAssociation ($ tableAlias )) {
122121 $ table ->{$ tagsAlias }
123122 ->belongsToMany ($ tableAlias , [
@@ -188,7 +187,7 @@ public function attachCounters()
188187 if (!$ counterCache ->getConfig ($ taggedAlias )) {
189188 $ field = key ($ config ['taggedCounter ' ]);
190189 $ config ['taggedCounter ' ]['tag_count ' ]['conditions ' ] = [
191- $ taggedTable ->aliasField ($ this ->getConfig ('fkTableField ' )) => $ this ->_table ->getTable ()
190+ $ taggedTable ->aliasField ($ this ->getConfig ('fkTableField ' )) => $ this ->_table ->getTable (),
192191 ];
193192 $ counterCache ->setConfig ($ this ->_table ->getAlias (), $ config ['taggedCounter ' ]);
194193 }
@@ -209,7 +208,8 @@ public function normalizeTags($tags)
209208 $ result = [];
210209
211210 $ common = ['_joinData ' => [$ this ->getConfig ('fkTableField ' ) => $ this ->_table ->getTable ()]];
212- if ($ namespace = $ this ->getConfig ('namespace ' )) {
211+ $ namespace = $ this ->getConfig ('namespace ' );
212+ if ($ namespace ) {
213213 $ common += compact ('namespace ' );
214214 }
215215
@@ -230,7 +230,7 @@ public function normalizeTags($tags)
230230 }
231231 list ($ id , $ label ) = $ this ->_normalizeTag ($ tag );
232232 $ result [] = $ common + compact (empty ($ id ) ? $ df : $ pk ) + [
233- 'tag_key ' => $ tagKey
233+ 'tag_key ' => $ tagKey,
234234 ];
235235 }
236236
@@ -245,7 +245,7 @@ public function normalizeTags($tags)
245245 */
246246 protected function _getTagKey ($ tag )
247247 {
248- return strtolower (Text::slug ($ tag ));
248+ return strtolower (Text::slug ($ tag ));
249249 }
250250
251251 /**
@@ -262,12 +262,13 @@ protected function _tagExists($tag)
262262 $ tagsTable ->aliasField ('tag_key ' ) => $ tag ,
263263 ])
264264 ->select ([
265- $ tagsTable ->aliasField ($ tagsTable ->getPrimaryKey ())
265+ $ tagsTable ->aliasField ($ tagsTable ->getPrimaryKey ()),
266266 ])
267267 ->first ();
268268 if (!empty ($ result )) {
269269 return $ result ->id ;
270270 }
271+
271272 return null ;
272273 }
273274
@@ -289,7 +290,7 @@ protected function _normalizeTag($tag)
289290
290291 return [
291292 trim ($ namespace ),
292- trim ($ label )
293+ trim ($ label ),
293294 ];
294295 }
295296}
0 commit comments