/**
  * Lazy loads plugins from attached plugin manager and sorts them by name
  *
  * @return array
  */
 protected function getPlugins()
 {
     if (is_array($this->plugins)) {
         return $this->plugins;
     }
     // Add invokableClasses via reflection
     $reflClass = new \ReflectionClass($this->pluginManager);
     $reflProp = $reflClass->getProperty('invokableClasses');
     $reflProp->setAccessible(true);
     $invokables = array_flip($reflProp->getValue($this->pluginManager));
     $plugins = array_merge($invokables, $this->pluginManager->getCanonicalNames());
     foreach ($plugins as $name => $canonical) {
         $this->plugins[] = $name;
     }
     sort($this->plugins, SORT_STRING);
     return $this->plugins;
 }
Esempio n. 2
0
 /**
  * Create new entity manager
  *
  * @return \Doctrine\ORM\EntityManager
  */
 public function newEntityManager()
 {
     $newEntityManager = $this->locator->create('doctrine.entitymanager.orm_default');
     $this->entityManager = $newEntityManager;
     foreach ($this->locator->getCanonicalNames() as $alias => $canonicalName) {
         if (strstr($alias, '\\Service\\')) {
             $service = $this->locator->get($alias);
             if ($service instanceof AbstractService) {
                 $service->setObjectManager($newEntityManager);
             }
         }
     }
     return $newEntityManager;
 }
 protected function cleanupServiceManager(\Zend\ServiceManager\ServiceManager $serviceManager)
 {
     // Cleanup: ServiceManager
     $cnames = $serviceManager->getCanonicalNames();
     foreach ($cnames as $name => $cname) {
         $serviceManager->setService($name, null);
     }
 }