Пример #1
0
 /**
  * @see BackBee\Config\Persistor\PersistorInterface::persist
  */
 public function persist(Config $config, array $configToPersist)
 {
     if (array_key_exists('override_site', $configToPersist)) {
         $configToPersist = array('override_site' => $configToPersist['override_site']);
     }
     $baseScope = 'BUNDLE_CONFIG.';
     $key = $this->app->getContainer()->get('bundle.loader')->getBundleIdByBaseDir($config->getBaseDir());
     if (null === $key) {
         $key = $application;
         $baseScope = 'APPLICATION_CONFIG.';
     }
     $scope = $baseScope . $this->app->getContext() . '.' . $this->app->getEnvironment();
     $registry = $this->app->getEntityManager()->getRepository('BackBee\\Bundle\\Registry')->findOneBy(array('key' => $key, 'scope' => $scope));
     if (null === $registry) {
         $registry = new RegistryEntity();
         $registry->setKey($key);
         $registry->setScope($scope);
         $this->app->getEntityManager()->persist($registry);
     }
     $registry->setValue(serialize($configToPersist));
     $success = true;
     try {
         $this->app->getEntityManager()->flush($registry);
     } catch (\Exception $e) {
         $success = false;
     }
     return $success;
 }
 /**
  * Instantiate a ClassContentManager.
  *
  * @param ApplicationInterface   $app      The current application.
  * @param IconizerInterface|null $iconizer Optional, an content iconizer.
  */
 public function __construct(ApplicationInterface $app, IconizerInterface $iconizer = null)
 {
     $this->app = $app;
     $this->entityManager = $app->getEntityManager();
     $this->iconizer = $iconizer;
     $this->cache = $app->getContainer()->get('cache.control');
 }
Пример #3
0
 /**
  * @param string $controllerName
  * @param string $actionName
  */
 protected function createController($controllerName, $actionName = null)
 {
     $controllerClass = null;
     if (null === $actionName) {
         // support for ControllerClass::methodName notation
         if (false !== strpos($controllerName, '::')) {
             list($controllerClass, $actionName) = explode('::', $controllerName, 2);
         } else {
             throw new \LogicException(sprintf('Unable to extract controller action from "%s".', $controllerName));
         }
     } else {
         $controllerClass = $controllerName;
     }
     if (null === $controllerClass) {
         throw new \InvalidArgumentException(sprintf('Controller class couldn\'t be resolved for "%s".', $controllerName));
     }
     if (class_exists($controllerClass)) {
         $controller = new $controllerClass();
         if ($controller instanceof ContainerAwareInterface) {
             $controller->setContainer($this->bbapp->getContainer());
         }
     } else {
         // support for service id
         $controller = $this->bbapp->getContainer()->get($controllerClass);
     }
     return array($controller, $actionName);
 }
Пример #4
0
 /**
  * Class constructor.
  *
  * @access public
  *
  * @param ApplicationInterface $application The current BBapplication
  */
 public function __construct(ApplicationInterface $application = null)
 {
     if (null !== $application) {
         $this->application = $application;
         $this->container = $application->getContainer();
     }
 }
 /**
  * Returns the container base folder for thumnails or null 
  * 
  * @return string|null
  */
 private function getBaseFolder()
 {
     $container = $this->application->getContainer();
     if (null === $this->baseFolder && $container->hasParameter('classcontent_thumbnail.base_folder')) {
         $this->baseFolder = $container->getParameter('classcontent_thumbnail.base_folder');
     }
     return $this->baseFolder;
 }
Пример #6
0
 /**
  * Returns path to the right directory to dump and save config.yml file.
  *
  * @param string $baseDir config base directory
  *
  * @return string
  */
 private function getConfigDumpRightDirectory($baseDir)
 {
     $configDumpDir = $this->app->getRepository();
     if (ApplicationInterface::DEFAULT_CONTEXT !== $this->app->getContext()) {
         $configDumpDir .= DIRECTORY_SEPARATOR . $this->app->getContext();
     }
     $configDumpDir .= DIRECTORY_SEPARATOR . 'Config';
     if (ApplicationInterface::DEFAULT_ENVIRONMENT !== $this->app->getEnvironment()) {
         $configDumpDir .= DIRECTORY_SEPARATOR . $this->app->getEnvironment();
     }
     $key = $this->app->getContainer()->get('bundle.loader')->getBundleIdByBaseDir($baseDir);
     if (null !== $key) {
         $configDumpDir .= DIRECTORY_SEPARATOR . 'bundle' . DIRECTORY_SEPARATOR . $key;
     }
     if (!is_dir($configDumpDir) && false === @mkdir($configDumpDir, 0755, true)) {
         throw new \Exception('Unable to create config dump directory');
     }
     return $configDumpDir;
 }
Пример #7
0
 /**
  * Builds bundle Config definition.
  *
  * @param string $baseDir The bundle base directory
  *
  * @return \Symfony\Component\DependencyInjection\Definition
  */
 private function buildConfigDefinition($baseDir)
 {
     $definition = new Definition('BackBee\\Config\\Config', array($this->getConfigDirByBundleBaseDir($baseDir), new Reference('cache.bootstrap'), null, '%debug%', '%config.yml_files_to_ignore%'));
     if (true === $this->application->getContainer()->getParameter('container.autogenerate')) {
         $definition->addTag('dumpable', array('dispatch_event' => false));
     }
     $definition->addMethodCall('setContainer', array(new Reference('service_container')));
     $definition->addMethodCall('setEnvironment', array('%bbapp.environment%'));
     $definition->setConfigurator(array(new Reference('config.configurator'), 'configureBundleConfig'));
     $definition->addTag('bundle.config', array('dispatch_event' => false));
     return $definition;
 }
Пример #8
0
 /**
  * Class constructor.
  *
  * @param ApplicationInterface|null $application Optional, the current application.
  * @param LoggerInterface|null      $logger      Optional, a message logger
  */
 public function __construct(ApplicationInterface $application = null, LoggerInterface $logger = null)
 {
     $this->application = $application;
     $this->logger = $logger;
     $this->isRestored = false;
     $this->rawRoutes = [];
     $this->uriPrefixes = [];
     $this->defaultScheme = '';
     if (null !== $this->application && null !== ($container = $this->application->getContainer())) {
         $this->readFromContainer($container);
     }
 }
Пример #9
0
 /**
  * @param Event $event
  */
 public function onGetServiceConfig(Event $event)
 {
     if (true === $this->application->isStarted()) {
         $config = $event->getTarget();
         if (null !== ($override_site = $config->getRawSection('override_site'))) {
             if (array_key_exists($this->application->getSite()->getUid(), $override_site)) {
                 foreach ($override_site[$this->application->getSite()->getUid()] as $section => $data) {
                     $config->setSection($section, $data, true);
                 }
             }
         }
         $this->application->getContainer()->getDefinition($event->getArgument('id'))->clearTag('config_per_site');
     }
 }
Пример #10
0
 /**
  * {@inheritdoc}
  */
 public function __construct(ApplicationInterface $application, $persistPerContext, $persistPerEnvironment)
 {
     $this->container = $application->getContainer();
 }
Пример #11
0
 /**
  * CategoryManager's constructor.
  *
  * @param ApplicationInterface $application application from where we will extract classcontent's categories
  */
 public function __construct(ApplicationInterface $application)
 {
     $this->categories = [];
     $this->options = ['thumbnail_url_pattern' => $application->getRouting()->getUrlByRouteName('bb.classcontent_thumbnail', ['filename' => '%s.' . $application->getContainer()->getParameter('classcontent_thumbnail.extension')])];
     $this->loadCategoriesFromClassContentDirectories($application->getClassContentDir());
 }
Пример #12
0
 /**
  * @param ApplicationInterface $application
  */
 public function __construct(ApplicationInterface $application)
 {
     $this->application = $application;
     $this->container = $application->getContainer();
     $this->isRestored = false;
 }
Пример #13
0
 /**
  * Loads ToolbarBundle and BBCoreJs resources directories into application.
  *
  * @param  BBApplication $application
  * @param  Config        $config
  */
 public static function loadResources(ApplicationInterface $application, Config $config)
 {
     $baseDir = $application->getContainer()->get('bundle.theme')->getBaseDirectory();
     $application->addResourceDir($baseDir . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'resources');
 }
Пример #14
0
 /**
  * Instantiate a ClassContentManager.
  *
  * @param ApplicationInterface $application
  */
 public function __construct(ApplicationInterface $application)
 {
     $this->application = $application;
     $this->em = $application->getEntityManager();
     $this->categoryManager = $application->getContainer()->get('classcontent.category_manager');
 }
Пример #15
0
 /**
  * @see BackBee\Bundle\BundleInterface::getConfig
  */
 public function getConfig()
 {
     return $this->application->getContainer()->get($this->getConfigServiceId());
 }
Пример #16
0
 /**
  * {@inheritdoc}
  */
 public function __construct(ApplicationInterface $application)
 {
     $this->container = $application->getContainer();
 }