Beispiel #1
0
 /**
  * Constructor.
  *
  * @param ContainerInterface $container
  * @param AbstractModule $bundle
  */
 public function __construct(ContainerInterface $container, AbstractModule $bundle)
 {
     $this->container = $container;
     $this->entityManager = $container->get('doctrine.entitymanager');
     $this->name = $bundle->getName();
     $this->view = Zikula_View::getInstance($this->name);
     parent::__construct(ZLanguage::getModuleDomain($this->name));
 }
Beispiel #2
0
 /**
  * Load routes of the specified module from the module's configuration file.
  *
  * @param AbstractModule $module
  *
  * @return RouteCollection
  */
 public function find(AbstractModule $module)
 {
     try {
         $path = $this->kernel->locateResource($module->getRoutingConfig());
     } catch (\InvalidArgumentException $e) {
         // Routing file does not exist (e.g. because the bundle could not be located)
         return new RouteCollection();
     }
     $modname = $module->getName();
     $this->logger->info('Loading routes for ' . $modname);
     return $this->loader->import($path);
 }
 public function build(ContainerBuilder $container)
 {
     parent::build($container);
     $container->addCompilerPass(new MediaTypeCompilerPass());
     $container->addCompilerPass(new CollectionTemplateCompilerPass());
     $container->addCompilerPass(new FontCompilerPass());
 }
Beispiel #4
0
 /**
  * Get an instance of the module installer class
  * @param \Zikula\Core\AbstractModule|null $module
  * @param array $modInfo
  * @return \Zikula_AbstractInstaller|\Zikula\Core\ExtensionInstallerInterface
  */
 private function getInstaller($module, array $modInfo)
 {
     if (null === $module) {
         $className = ucwords($modInfo['name']) . '\\' . ucwords($modInfo['name']) . 'Installer';
         $classNameOld = ucwords($modInfo['name']) . '_Installer';
         $className = class_exists($className) ? $className : $classNameOld;
     } else {
         $className = $module->getInstallerClass();
     }
     $reflectionInstaller = new ReflectionClass($className);
     if ($reflectionInstaller->isSubclassOf('Zikula_AbstractInstaller')) {
         $installer = $reflectionInstaller->newInstanceArgs(array($this->serviceManager, $module));
     } elseif ($reflectionInstaller->isSubclassOf('\\Zikula\\Core\\ExtensionInstallerInterface')) {
         $installer = $reflectionInstaller->newInstance();
         $installer->setBundle($module);
         if ($installer instanceof ContainerAwareInterface) {
             $installer->setContainer($this->getContainer());
         }
     } else {
         throw new \RuntimeException($this->__f("%s must be an instance of Zikula_AbstractInstaller or implement ExtensionInstallerInterface", $className));
     }
     return $installer;
 }
Beispiel #5
0
 /**
  * @param AbstractModule $module
  * @param bool $userRoutes
  * @return bool
  */
 public function removeAllOfModule(AbstractModule $module, $userRoutes = false)
 {
     $routes = $this->findBy(array('userRoute' => $userRoutes, 'bundle' => $module->getName()));
     if (empty($routes)) {
         return false;
     }
     $workflowHelper = new WorkflowUtil(\ServiceUtil::getManager(), \ModUtil::getModule('ZikulaRoutesModule'));
     foreach ($routes as $routeEntity) {
         $workflowHelper->executeAction($routeEntity, 'delete');
     }
     return true;
 }
Beispiel #6
0
 /**
  * Get the block directory for a module given an instance of the module or (for BC purposes), the module name.
  *  The $moduleName parameter is deprecated and will be removed at Core-2.0
  *
  * @param AbstractModule|null $moduleInstance
  * @param null $moduleName (parameter is @deprecated)
  * @return array
  */
 public function getModuleBlockPath(AbstractModule $moduleInstance = null, $moduleName = null)
 {
     $path = null;
     $nameSpace = null;
     if (isset($moduleInstance)) {
         if (is_dir($moduleInstance->getPath() . '/Block')) {
             $path = $moduleInstance->getPath() . '/Block';
             $nameSpace = $moduleInstance->getNamespace() . '\\Block\\';
         }
     } elseif (isset($moduleName)) {
         // @todo remove at Core-2.0
         $testPath = realpath($this->kernelRootDir . '/../modules/' . $moduleName . '/lib/' . $moduleName . '/Block');
         if (is_dir($testPath)) {
             $path = $testPath;
             $nameSpace = '\\';
         }
     }
     return [$nameSpace, $path];
 }