/** * boot the controller * * @param AbstractBundle $bundle */ public function boot(AbstractBundle $bundle) { // load optional bootstrap $bootstrap = $bundle->getPath() . "/bootstrap.php"; if (file_exists($bootstrap)) { include_once $bootstrap; } // load any plugins // @todo adjust this when Namespaced plugins are implemented \PluginUtil::loadPlugins($bundle->getPath() . "/plugins", "ModulePlugin_{$this->name}"); }
/** * @param ContainerInterface|null $container */ public function setContainer(ContainerInterface $container = null) { $this->container = $container; $this->setTranslator($container->get('translator')); $this->entityManager = $container->get('doctrine.entitymanager'); $this->schemaTool = $container->get('zikula.doctrine.schema_tool'); $this->extensionName = $this->name; // for ExtensionVariablesTrait $this->variableApi = $container->get('zikula_extensions_module.api.variable'); // for ExtensionVariablesTrait $this->hookApi = $container->get('zikula_extensions_module.api.hook'); if ($this->bundle) { $container->get('translator')->setDomain($this->bundle->getTranslationDomain()); } }
/** * create the category tree * * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException If Root category not found. * @throws \Exception * * @return boolean */ private function createCategoryTree() { // create category \CategoryUtil::createCategory('/__SYSTEM__/Modules', $this->bundle->getName(), null, $this->__('Gallery'), $this->__('Gallery categories')); // create subcategory \CategoryUtil::createCategory('/__SYSTEM__/Modules/KaikmediaGalleryModule', 'Category1', null, $this->__('Category 1'), $this->__('Initial sub-category created on install'), array('color' => '#99ccff')); \CategoryUtil::createCategory('/__SYSTEM__/Modules/KaikmediaGalleryModule', 'Category2', null, $this->__('Category 2'), $this->__('Initial sub-category created on install'), array('color' => '#cceecc')); // get the category path to insert Pages categories $rootcat = \CategoryUtil::getCategoryByPath('/__SYSTEM__/Modules/KaikmediaGalleryModule'); if ($rootcat) { // create an entry in the categories registry to the Main property if (!\CategoryRegistryUtil::insertEntry($this->bundle->getName(), 'AlbumEntity', 'Main', $rootcat['id'])) { throw new \Exception('Cannot insert Category Registry entry.'); } } else { throw new NotFoundHttpException('Root category not found.'); } return true; }
public function setDirectoryFromBundle(\Zikula\Core\AbstractBundle $bundle) { $parts = explode('/', $bundle->getRelativePath()); array_shift($parts); $this->directory = implode('/', $parts); }
/** * Prepends the bundle prefix to the route. * * @param Route $route * @param AbstractBundle $bundle * * We have to prepend the bundle prefix if * - routes are _not_ currently extracted via the command line and * - the route has i18n set to false. * This is because when extracting the routes, a bundle author only wants to translate the bare route * patterns, without a redundant and potentially customized bundle prefix in front of them. * If i18n is set to true, Zikula's customized pattern generation strategy will take care of it. * See Zikula\RoutesModule\Translation\ZikulaPatternGenerationStrategy */ private function prependBundlePrefix(Route $route, AbstractBundle $bundle) { $prefix = ''; $options = $route->getOptions(); $prependBundle = !isset($GLOBALS['translation_extract_routes']) && isset($options['i18n']) && !$options['i18n']; if ($prependBundle && (!isset($options['zkNoBundlePrefix']) || !$options['zkNoBundlePrefix'])) { // get url from MetaData first. May be empty. $untranslatedPrefix = $bundle->getMetaData()->getUrl(false); if (empty($untranslatedPrefix)) { try { // MetaData will be empty for extensions not Spec-2.0. Try to get from modinfo. // this calls the DB which is not available during install. $modinfo = \ModUtil::getInfoFromName($bundle->getName()); $prefix = $modinfo['url']; } catch (\Exception $e) { } } else { $locale = $this->container->getParameter('locale'); if ($this->translator->getCatalogue($locale)->has($untranslatedPrefix, strtolower($bundle->getName()))) { $prefix = $this->translator->trans($untranslatedPrefix, [], strtolower($bundle->getName()), $locale); } else { $prefix = $untranslatedPrefix; } } $path = "/" . $prefix . $route->getPath(); $route->setPath($path); } }