Domanda

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 ?

È stato utile?

Soluzione

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'];
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top