예제 #1
0
 /**
  * Constructor.
  *
  * @param AbstractBundle $bundle
  *            A AbstractBundle instance
  * @throws \InvalidArgumentException
  */
 public function __construct(AbstractBundle $bundle)
 {
     $this->name = $bundle->getName();
     $this->translator = $bundle->getContainer()->get('translator');
     $this->translator->setDomain($bundle->getTranslationDomain());
     $this->boot($bundle);
 }
예제 #2
0
 public function setBundle(AbstractBundle $bundle)
 {
     $this->bundle = $bundle;
     $this->name = $bundle->getName();
     if ($this->container) {
         // both here and in `setContainer` so either method can be called first.
         $this->container->get('translator')->setDomain($this->bundle->getTranslationDomain());
     }
 }
예제 #3
0
 /**
  * Constructor.
  *
  * @param AbstractBundle $bundle
  *            A AbstractBundle instance
  * @throws \InvalidArgumentException
  */
 public function __construct(AbstractBundle $bundle)
 {
     $this->name = $bundle->getName();
     $this->extensionName = $this->name;
     // for ExtensionVariablesTrait
     $this->variableApi = $bundle->getContainer()->get('zikula_extensions_module.api.variable');
     // for ExtensionVariablesTrait
     $this->setTranslator($bundle->getContainer()->get('translator'));
     $this->translator->setDomain($bundle->getTranslationDomain());
     $this->boot($bundle);
 }
 /**
  * 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;
 }
예제 #5
0
 /**
  * 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);
     }
 }