How can I get every class that implements or extends from a specific class ? For example I want to get all of classes that instantiated from MyClassName class ?
Asked
Active
Viewed 56 times
1 Answers
-1
You can do what Exlord said , but if you want something framework specific , you can add your preferd classes in config file under a specific key and get all of them .
for example :
Module A :
return array(
'MyClassName' => array(
'Module\Service\ClassA' => 'Course\Service\ClassA',
'Module\Service\ClassB' => 'Course\Service\ClassB',
);
Module B :
return array(
'MyClassName' => array(
'Module\Service\ClassC' => 'Course\Service\ClassC',
);
and get all of MyClassName instances like this :
$config = $this->getServiceLocator()->get('config');
$MyClassNameInstances = $config['MyClassName'];

Mostafa Solati
- 1,235
- 2
- 13
- 33
-
1This is wrong, and it is not related with what the original author asked. This is just configuration and manual mappings. The correct response is by @Exlord – Ocramius Mar 09 '14 at 10:39