Beispiel #1
0
 /**
  * Factory class to create instance of HookContainer class defined in MetaData::capabilities.
  * @param MetaData $metaData
  * @param null $requestedHookType
  * @return null|\Zikula\Component\HookDispatcher\AbstractContainer
  */
 public function getHookContainerInstance(MetaData $metaData, $requestedHookType = null)
 {
     foreach ([self::SUBSCRIBER_TYPE, self::PROVIDER_TYPE] as $type) {
         if (isset($metaData->getCapabilities()[$type]['class']) && (!isset($requestedHookType) || $type == $requestedHookType)) {
             $hookContainerClassName = $metaData->getCapabilities()[$type]['class'];
             $reflection = new \ReflectionClass($hookContainerClassName);
             if ($reflection->isSubclassOf('Zikula\\Component\\HookDispatcher\\AbstractContainer')) {
                 return new $hookContainerClassName($this->translator);
             }
         }
     }
     return null;
 }
Beispiel #2
0
 private function insert(MetaData $metadata)
 {
     $name = $metadata->getName();
     $autoload = serialize($metadata->getAutoload());
     $class = $metadata->getClass();
     switch ($metadata->getType()) {
         case 'zikula-module':
             $type = 'M';
             break;
         case 'zikula-theme':
             $type = 'T';
             break;
         case 'zikula-plugin':
             $type = 'P';
             break;
         default:
             throw new \InvalidArgumentException(sprintf('Unknown type %s', $metadata->getType()));
     }
     $this->conn->insert('bundles', array('bundlename' => $name, 'autoload' => $autoload, 'bundleclass' => $class, 'bundletype' => $type, 'bundlestate' => AbstractBundle::STATE_ACTIVE));
 }
Beispiel #3
0
 /**
  * @covers Zikula\Bundle\CoreBundle\Bundle\MetaData::getNamespace
  */
 public function testGetNamespace()
 {
     $this->assertEquals('Zikula\\Module\\AdminModule\\', $this->metaData->getNamespace());
 }
Beispiel #4
0
 /**
  * @return MetaData
  */
 public function getMetaData()
 {
     $scanner = new Scanner();
     $jsonPath = $this->getPath() . '/composer.json';
     $jsonContent = $scanner->decode($jsonPath);
     $metaData = new MetaData($jsonContent);
     if (!empty($this->container)) {
         $metaData->setTranslator($this->container->get('translator'));
     }
     $metaData->setDirectoryFromBundle($this);
     return $metaData;
 }