@@ -47,7 +47,6 @@ class TaggableBehavior extends Behavior
4747 public function events ()
4848 {
4949 return [
50- ActiveRecord::EVENT_AFTER_FIND => 'afterFind ' ,
5150 ActiveRecord::EVENT_AFTER_INSERT => 'afterSave ' ,
5251 ActiveRecord::EVENT_AFTER_UPDATE => 'afterSave ' ,
5352 ActiveRecord::EVENT_BEFORE_DELETE => 'beforeDelete ' ,
@@ -61,10 +60,13 @@ public function events()
6160 */
6261 public function getTagNames ($ asArray = null )
6362 {
64- if (!$ this ->owner ->getIsNewRecord ()
65- && $ this ->_tagNames === null
66- && !$ this ->owner ->isRelationPopulated ($ this ->tagRelation )) {
67- $ this ->populateTagNames ();
63+ if (!$ this ->owner ->getIsNewRecord () && $ this ->_tagNames === null ) {
64+ $ this ->_tagNames = [];
65+
66+ /* @var ActiveRecord $tag */
67+ foreach ($ this ->owner ->{$ this ->tagRelation } as $ tag ) {
68+ $ this ->_tagNames [] = $ tag ->getAttribute ($ this ->tagNameAttribute );
69+ }
6870 }
6971
7072 if ($ asArray === null ) {
@@ -123,16 +125,6 @@ public function hasTagNames($names)
123125 return true ;
124126 }
125127
126- /**
127- * @return void
128- */
129- public function afterFind ()
130- {
131- if ($ this ->owner ->isRelationPopulated ($ this ->tagRelation )) {
132- $ this ->populateTagNames ();
133- }
134- }
135-
136128 /**
137129 * @return void
138130 */
@@ -222,17 +214,4 @@ public function filterTagNames($names)
222214 PREG_SPLIT_NO_EMPTY
223215 );
224216 }
225-
226- /**
227- * @return void
228- */
229- protected function populateTagNames ()
230- {
231- $ this ->_tagNames = [];
232-
233- /* @var ActiveRecord $tag */
234- foreach ($ this ->owner ->{$ this ->tagRelation } as $ tag ) {
235- $ this ->_tagNames [] = $ tag ->getAttribute ($ this ->tagNameAttribute );
236- }
237- }
238217}
0 commit comments