Symfony Container - tags services implementing an interface
The getClass()
method of the Definition
class returns the class configured for a particular service. You can then use the is_subclass_of()
function to check if this class implements a certain interface (this works since PHP 5.3.7):
if (is_subclass_of($definition->getClass(), 'SomeInterface')) { // do whatever you want here}
You need to be careful though to let your compiler pass run as late as possible as other passes might still change the class of a definition after your pass has been executed.