File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed
src/Symfony/Component/DependencyInjection Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -451,6 +451,22 @@ public function hasTag($name)
451
451
return isset ($ this ->tags [$ name ]);
452
452
}
453
453
454
+ /**
455
+ * Clears all tags for a given name.
456
+ *
457
+ * @param string $name The tag name
458
+ *
459
+ * @return Definition
460
+ */
461
+ public function clearTag ($ name )
462
+ {
463
+ if (isset ($ this ->tags [$ name ])) {
464
+ unset($ this ->tags [$ name ]);
465
+ }
466
+
467
+ return $ this ;
468
+ }
469
+
454
470
/**
455
471
* Clears the tags for this definition.
456
472
*
Original file line number Diff line number Diff line change @@ -187,6 +187,25 @@ public function testClearTags()
187
187
$ this ->assertEquals (array (), $ def ->getTags (), '->clearTags() removes all current tags ' );
188
188
}
189
189
190
+ /**
191
+ * @covers Symfony\Component\DependencyInjection\Definition::clearTags
192
+ */
193
+ public function testClearTag ()
194
+ {
195
+ $ def = new Definition ('stdClass ' );
196
+ $ this ->assertSame ($ def , $ def ->clearTags (), '->clearTags() implements a fluent interface ' );
197
+ $ def ->addTag ('1foo1 ' , array ('foo1 ' => 'bar1 ' ));
198
+ $ def ->addTag ('2foo2 ' , array ('foo2 ' => 'bar2 ' ));
199
+ $ def ->addTag ('3foo3 ' , array ('foo3 ' => 'bar3 ' ));
200
+ $ def ->clearTag ('2foo2 ' );
201
+ $ this ->assertTrue ($ def ->hasTag ('1foo1 ' ));
202
+ $ this ->assertFalse ($ def ->hasTag ('2foo2 ' ));
203
+ $ this ->assertTrue ($ def ->hasTag ('3foo3 ' ));
204
+ $ def ->clearTag ('1foo1 ' );
205
+ $ this ->assertFalse ($ def ->hasTag ('1foo1 ' ));
206
+ $ this ->assertTrue ($ def ->hasTag ('3foo3 ' ));
207
+ }
208
+
190
209
/**
191
210
* @covers Symfony\Component\DependencyInjection\Definition::addTag
192
211
* @covers Symfony\Component\DependencyInjection\Definition::getTag
You can’t perform that action at this time.
<
D47
/path>
0 commit comments