/** * Method called on serializer.post_serialize event for Page object. * * @param \JMS\Serializer\EventDispatcher\ObjectEvent $event */ public function onPostSerialize(ObjectEvent $event) { if ($this->container->has('routing')) { $uri = $this->container->get('routing')->getUri($event->getObject()->getUrl()); $event->getVisitor()->addData('uri', $uri); } }
/** * Resolve the bundle controller by passing two identifier (bundle and controller) and return it. * * @param String $bundle Bundle identifier used to declare it into bundle.yml * @param String $controller Controller identifier used to declare it inte your bundle configuration * @return \BackBee\Bundle\AbstractBundleController * * @throws Exception Bad configuration */ public function resolve($bundle, $controller) { if (!$this->container->has($this->computeBundleName($bundle))) { throw new BundleConfigurationException($bundle . ' doesn\'t exists', BundleConfigurationException::BUNDLE_UNDECLARED); } $config = $this->container->get($this->computeBundleName($bundle))->getProperty(); if (!isset($config['admin_controller'])) { throw new BundleConfigurationException('No controller definition in ' . $bundle . ' bundle configuration', BundleConfigurationException::CONTROLLER_SECTION_MISSING); } if (!isset($config['admin_controller'][$controller])) { throw new BundleConfigurationException($controller . ' controller is undefinned in ' . $bundle . ' bundle configuration', BundleConfigurationException::CONTROLLER_UNDECLARED); } $namespace = '\\' . $config['admin_controller'][$controller]; return new $namespace($this->application); }
/** * @codeCoverageIgnore * Returns a new ORM Configuration. * * @param array $options Optional, the options to create the new Configuration * @return Configuration */ private static function getORMConfiguration(array $options = array(), LoggerInterface $logger = null, ContainerInterface $container = null) { $config = new Configuration(); $driverImpl = $config->newDefaultAnnotationDriver([], false); $config->setMetadataDriverImpl($driverImpl); if (isset($options['proxy_dir'])) { $config->setProxyDir($options['proxy_dir']); } if (isset($options['proxy_ns'])) { $config->setProxyNamespace($options['proxy_ns']); } if (isset($options['orm'])) { if (isset($options['orm']['proxy_namespace'])) { $config->setProxyNamespace($options['orm']['proxy_namespace']); } if (isset($options['orm']['proxy_dir'])) { $config->setProxyDir($options['orm']['proxy_dir']); } if (isset($options['orm']['auto_generate_proxy_classes'])) { $config->setAutoGenerateProxyClasses($options['orm']['auto_generate_proxy_classes']); } if (isset($options['orm']['metadata_cache_driver']) && is_array($options['orm']['metadata_cache_driver'])) { if (isset($options['orm']['metadata_cache_driver']['type'])) { if ('service' === $options['orm']['metadata_cache_driver']['type'] && isset($options['orm']['metadata_cache_driver']['id'])) { $serviceId = str_replace('@', '', $options['orm']['metadata_cache_driver']['id']); if (null !== $container && $container->has($serviceId)) { $config->setMetadataCacheImpl($container->get($serviceId)); } } } } if (isset($options['orm']['query_cache_driver']) && is_array($options['orm']['query_cache_driver'])) { if (isset($options['orm']['query_cache_driver']['type'])) { if ('service' === $options['orm']['query_cache_driver']['type'] && isset($options['orm']['query_cache_driver']['id'])) { $serviceId = str_replace('@', '', $options['orm']['query_cache_driver']['id']); if (null !== $container && $container->has($serviceId)) { $config->setQueryCacheImpl($container->get($serviceId)); } } } } } if ($logger instanceof SQLLogger) { $config->setSQLLogger($logger); } return self::addCustomFunctions($config, $options); }
/** * @depends testTryRestoreDumpableService */ public function testHas(ContainerInterface $container) { $this->assertFalse($container->has('service_zero')); $this->assertTrue($container->has('service_one') && $container->has('service_two') && $container->has('service_three') && $container->has('service_four') && $container->has('service_five') && $container->has('service_six') && $container->has('service_seven') && $container->has('service_eight') && $container->has('service_nine') && $container->has('service_ten') && $container->has('service_eleven')); return $container; }