Exemplo n.º 1
0
 /**
  * This command enables a template
  *
  * @param InputInterface  $input  The input interface
  * @param OutputInterface $output The output interface
  *
  * @return void
  *
  * @throws Exception Template nof found
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $templateName = $input->getArgument('template');
     $templates = $this->configurationManager->get('store.templates');
     $templateFound = array_reduce($templates, function ($alreadyFound, $template) use($templateName) {
         return $alreadyFound || $template['bundle'] == $templateName;
     }, false);
     if (!$templateFound) {
         throw new Exception(sprintf('Template %s not found', $templateName));
     }
     $this->configurationManager->set('store.template', $templateName);
     $formatter = $this->getHelper('formatter');
     $formattedLine = $formatter->formatSection('OK', 'Template "' . $templateName . '" enabled');
     $output->writeln($formattedLine);
 }
Exemplo n.º 2
0
 /**
  * Load templates
  *
  * @return array Templates found
  *
  * @throws ConfigurationParameterNotFoundException Parameter not found
  * @throws Exception                               ConfigurationBundle not installed
  */
 public function loadTemplates()
 {
     if (!$this->configurationManager instanceof ConfigurationManager) {
         throw new Exception('You need to install ConfigurationBundle');
     }
     $templates = new ArrayCollection([]);
     $bundles = $this->kernel->getBundles();
     /**
      * @var Bundle $bundle
      */
     foreach ($bundles as $bundle) {
         if ($bundle instanceof TemplateInterface) {
             $bundleName = $bundle->getName();
             $bundleNamespace = $bundle->getNamespace();
             $templates->set($bundleName, ['bundle' => $bundleName, 'namespace' => $bundleNamespace, 'name' => $bundle->getTemplateName()]);
         }
     }
     $templatesArray = $templates->toArray();
     $this->configurationManager->set('store.templates', $templatesArray);
     return $templatesArray;
 }
Exemplo n.º 3
0
 /**
  * Load a parameter given the key and the namespace
  *
  * @param string $parameterKey       Parameter key
  * @param string $parameterNamespace Parameter namespace
  *
  * @return null|string|boolean Configuration parameter value
  *
  * @throws ConfigurationParameterNotFoundException Configuration not found
  */
 public function getParameter($parameterKey, $parameterNamespace = '')
 {
     return $this->configurationManager->get($parameterKey, $parameterNamespace);
 }