Example #1
0
 public function testLoad()
 {
     $importedRouteCollection = new RouteCollection();
     $importedRouteCollection->add('route1', new Route('/example/route1'));
     $importedRouteCollection->add('route2', new Route('/route2'));
     $portal1 = new Portal();
     $portal1->setKey('sulu_lo');
     $portal2 = new Portal();
     $portal2->setKey('sulu_com');
     $portalInformations = [new PortalInformation(null, null, $portal1, null, 'sulu.io/de'), new PortalInformation(null, null, $portal2, null, 'sulu.com')];
     $this->loaderResolver->resolve(Argument::any(), Argument::any())->willReturn($this->loader->reveal());
     $this->loader->load(Argument::any(), Argument::any())->willReturn($importedRouteCollection);
     $this->webspaceManager->getPortalInformations(Argument::any())->willReturn($portalInformations);
     $routeCollection = $this->portalLoader->load('', 'portal');
     $this->assertCount(4, $routeCollection);
     $routes = $routeCollection->getIterator();
     $this->assertArrayHasKey('sulu.io/de.route1', $routes);
     $this->assertArrayHasKey('sulu.io/de.route2', $routes);
     $this->assertArrayHasKey('sulu.com.route1', $routes);
     $this->assertArrayHasKey('sulu.com.route2', $routes);
     $this->assertEquals('/de/example/route1', $routeCollection->get('sulu.io/de.route1')->getPath());
     $this->assertEquals('/de/route2', $routeCollection->get('sulu.io/de.route2')->getPath());
     $this->assertEquals('/example/route1', $routeCollection->get('sulu.com.route1')->getPath());
     $this->assertEquals('/route2', $routeCollection->get('sulu.com.route2')->getPath());
 }
Example #2
0
 /**
  * Loads the container configuration.
  *
  * @param LoaderInterface $loader A LoaderInterface instance
  * @api
  */
 public function registerContainerConfiguration(LoaderInterface $loader)
 {
     $loader->load(__DIR__ . '/Resources/config/default.yml');
     if ($this->config) {
         $loader->load(__DIR__ . '/Resources/config/' . $this->config);
     }
 }
Example #3
0
 public function registerContainerConfiguration(LoaderInterface $loader)
 {
     $loader->load(__DIR__ . '/config/config_' . $this->getEnvironment() . '.yml');
     if (is_file($file = __DIR__ . '/config/config_' . $this->getEnvironment() . '_local.yml')) {
         $loader->load($file);
     }
 }
Example #4
0
 public function registerContainerConfiguration(LoaderInterface $loader)
 {
     $file = $this->getRootDir() . '/config.yml';
     $contents = Yaml::dump($this->_config);
     file_put_contents($file, $contents);
     $loader->load($file);
 }
Example #5
0
 /**
  * You can modify the container here before it is dumped to PHP code.
  *
  * @param ContainerBuilder $container
  *
  * @api
  */
 public function process(ContainerBuilder $container)
 {
     $this->loader = $container->get('sulu.content.path_cleaner.replacer_loader');
     $service = $container->getDefinition('sulu.content.path_cleaner');
     $replacers = $this->loader->load($this->filename);
     $service->addArgument($replacers);
 }
 public function registerContainerConfiguration(LoaderInterface $loader)
 {
     $loader->load(__DIR__ . '/config/config_' . $this->getEnvironment() . '.yml');
     if (null !== $this->devConfig) {
         $loader->load($this->devConfig);
     }
 }
Example #7
0
 /**
  * {@inheritdoc}
  */
 public function registerContainerConfiguration(LoaderInterface $loader)
 {
     $loader->load(__DIR__ . '/config.yml');
     if (is_callable($this->configCallback)) {
         $loader->load($this->configCallback);
     }
 }
Example #8
0
 public function registerContainerConfiguration(LoaderInterface $loader)
 {
     $loader->load(__DIR__ . '/config/config_' . $this->getEnvironment() . '.yml');
     $loader->load(__DIR__ . '/config/security.yml');
     $loader->load(__DIR__ . '/config/roles.yml');
     $loader->load(__DIR__ . '/config/resources.yml');
 }
Example #9
0
 public function registerContainerConfiguration(LoaderInterface $loader)
 {
     if (!file_exists($filename = $this->getRootDir() . '/' . $this->testCase . '/config.yml')) {
         throw new \RuntimeException(sprintf('The config file "%s" does not exist.', $filename));
     }
     $loader->load($filename);
 }
Example #10
0
 public function registerContainerConfiguration(LoaderInterface $loader)
 {
     $loader->load(__DIR__ . '/config/config_plugin.yml');
     foreach ($this->pluginAdapter->getConfigurationFiles() as $file) {
         $loader->load($file);
     }
 }
Example #11
0
 public function registerContainerConfiguration(\Symfony\Component\Config\Loader\LoaderInterface $loader)
 {
     $config = array('secret' => '$ecret', 'router' => array('resource' => '%kernel.root_dir%/routing_test.yml'), 'form' => NULL, 'csrf_protection' => NULL, 'validation' => array('enable_annotations' => true), 'templating' => array('engines' => array(0 => 'twig')), 'fragments' => NULL, 'test' => NULL, 'session' => array('storage_id' => 'session.storage.mock_file'), 'profiler' => array('collect' => false));
     $loader->load(function (ContainerBuilder $container) use($config) {
         $container->loadFromExtension('framework', $config);
     });
 }
 public function registerContainerConfiguration(LoaderInterface $loader)
 {
     $loader->load($this->getRootDir() . '/config/config.yml');
     if ($this->isDebug()) {
         $loader->load($this->getRootDir() . '/config/config_dbg.yml');
     }
 }
Example #13
0
 public function registerContainerConfiguration(LoaderInterface $loader)
 {
     $loader->load(SuluTestBundle::getConfigDir() . '/config.php');
     if (class_exists('Sulu\\Bundle\\SearchBundle\\SuluSearchBundle')) {
         $loader->load(__DIR__ . '/config/search.yml');
     }
 }
Example #14
0
 public function build()
 {
     $finder = new Finder();
     $finder->in($this->path)->files()->name('*.xml')->sortByName();
     // Iterate over config files, and add a portal object for each config to the collection
     $collection = new WebspaceCollection();
     // reset arrays
     $this->webspaces = [];
     $this->portals = [];
     $this->portalInformations = [];
     foreach ($finder as $file) {
         // add file resource for cache invalidation
         $collection->addResource(new FileResource($file->getRealPath()));
         /** @var Webspace $webspace */
         $webspace = $this->loader->load($file->getRealPath());
         $this->webspaces[] = $webspace;
         $this->buildPortals($webspace);
     }
     $environments = array_keys($this->portalInformations);
     foreach ($environments as $environment) {
         // sort all portal informations by length
         uksort($this->portalInformations[$environment], function ($a, $b) {
             return strlen($a) < strlen($b);
         });
     }
     $collection->setWebspaces($this->webspaces);
     $collection->setPortals($this->portals);
     $collection->setPortalInformations($this->portalInformations);
     return $collection;
 }
 public function registerContainerConfiguration(LoaderInterface $loader)
 {
     $loader->load(__DIR__ . '/config/config.php');
     if ($this->getEnvironment() !== 'behat' && file_exists(ResourceContext::getConfigurationFile())) {
         $loader->import(ResourceContext::getConfigurationFile());
     }
 }
 public function onKernelRequest(GetResponseEvent $event)
 {
     if (null !== $this->loader) {
         // carrega os annotations para criar as rotas dos rests
         $this->loader->load('');
     }
 }
 /**
  * Loads the container configuration.
  *
  * @param LoaderInterface $loader A LoaderInterface instance
  *
  * @api
  */
 public function registerContainerConfiguration(LoaderInterface $loader)
 {
     if (null != $this->config) {
         $loader->load($this->config);
     }
     $loader->load(__DIR__ . '/config/default.yml');
 }
Example #18
0
 protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader)
 {
     $loader->load(__DIR__ . '/config/config.yml');
     if (isset($this->bundles['WebProfilerBundle'])) {
         $c->loadFromExtension('web_profiler', ['toolbar' => TRUE, 'intercept_redirects' => FALSE]);
     }
 }
Example #19
0
 public function registerContainerConfiguration(LoaderInterface $loader)
 {
     $loader->load(__DIR__ . '/config/' . $this->environment . '.yml');
     if (class_exists('Dunglas\\ApiBundle\\DunglasApiBundle')) {
         $loader->load(__DIR__ . '/config/dunglas_api.yml');
     }
 }
Example #20
0
 public function registerContainerConfiguration(LoaderInterface $loader)
 {
     $loader->load($this->config);
     if (PHP_VERSION_ID > 50400) {
         $loader->load(__DIR__ . '/config/traits.yml');
     }
 }
Example #21
0
 public function registerContainerConfiguration(LoaderInterface $loader)
 {
     $loader->load(function (ContainerBuilder $container) {
         $container->loadFromExtension('framework', ['secret' => 'abc123']);
         $container->loadFromExtension('wouterj_eloquent', ['driver' => 'sqlite', 'database' => '%kernel.root_dir%/test.sqlite', 'aliases' => true, 'eloquent' => true]);
     });
 }
 public function registerContainerConfiguration(LoaderInterface $loader)
 {
     $loader->load(__DIR__ . '/config/config_' . $this->getEnvironment() . '.yml');
     if (file_exists(__DIR__ . '/config/parameters.yml')) {
         $loader->load(__DIR__ . '/config/parameters.yml');
     }
 }
Example #23
0
 /**
  * @param ContainerBuilder $container
  * @param LoaderInterface $loader
  */
 private function prependHwiOauth(ContainerBuilder $container, LoaderInterface $loader)
 {
     if (!$container->hasExtension('hwi_oauth')) {
         return;
     }
     $loader->load('services/integrations/hwi_oauth.xml');
 }
Example #24
0
 /**
  * @param string $class
  * @return Metadata
  */
 public function getMetadataFor($class)
 {
     if (!array_key_exists($class, $this->metadata)) {
         $this->metadata[$class] = $this->loader->load($class);
     }
     return $this->metadata[$class];
 }
Example #25
0
 public function registerContainerConfiguration(LoaderInterface $loader)
 {
     $loader->load($this->getRootDir() . "/conf/services_" . $this->getEnvironment() . ".yml");
     if (file_exists($fileName = $this->getRootDir() . "/conf/services_local.yml")) {
         $loader->load($fileName);
     }
 }
Example #26
0
 /**
  * @param ContainerBuilder $container
  * @param LoaderInterface $loader
  */
 private function prependSyliusSettings(ContainerBuilder $container, LoaderInterface $loader)
 {
     if (!$container->hasExtension('sylius_settings')) {
         return;
     }
     $loader->load('integration/settings.xml');
 }
Example #27
0
 /**
  * @param mixed[]          $config
  * @param ContainerBuilder $container
  * @param LoaderInterface  $loader
  */
 private function loadSession(array $config, ContainerBuilder $container, LoaderInterface $loader)
 {
     if (!$config['enabled']) {
         return;
     }
     $loader->load('session.xml');
 }
 public function registerContainerConfiguration(LoaderInterface $loader)
 {
     $loader->load(function (ContainerBuilder $container) {
         $container->loadFromExtension('framework', array('secret' => 'this is a cool bundle. Shhh..., it\'s a secret...', 'router' => array('resource' => __DIR__ . '/routing.yml')));
         $container->loadFromExtension('knpu_oauth2_client', array('clients' => array('my_facebook' => array('type' => 'facebook', 'client_id' => 'FOOO', 'client_secret' => 'BAR', 'graph_api_version' => 'v2.5', 'redirect_route' => 'my_test_route'))));
     });
 }
Example #29
0
 /**
  * {@inheritdoc}
  */
 public function load($resource, $type = null)
 {
     if (true === $this->isLoaded) {
         throw new \RuntimeException('Do not add the "modera_routing" loader twice');
     }
     $resources = array();
     $items = $this->resourcesProvider->getItems();
     foreach ($items as $index => $resource) {
         if (!is_array($resource)) {
             $resource = array('resource' => $resource);
         }
         $resource = array_merge(array('order' => 0, 'type' => null), $resource);
         $resource['index'] = $index;
         $resources[] = $resource;
     }
     usort($resources, function ($a, $b) {
         if ($a['order'] == $b['order']) {
             return $a['index'] < $b['index'] ? -1 : 1;
         }
         return $a['order'] < $b['order'] ? -1 : 1;
     });
     $collection = new RouteCollection();
     foreach ($resources as $item) {
         $collection->addCollection($this->rootLoader->load($item['resource'], $item['type']));
     }
     $this->isLoaded = true;
     return $collection;
 }
Example #30
0
 public function registerContainerConfiguration(LoaderInterface $loader)
 {
     $file = 'config';
     if ('test' === $this->getEnvironment()) {
         $file .= '_test';
     }
     $loader->load(__DIR__ . '/config/$file.yml');
 }