本文整理汇总了PHP中Symfony\Component\DependencyInjection\ContainerBuilder::removeAlias方法的典型用法代码示例。如果您正苦于以下问题:PHP ContainerBuilder::removeAlias方法的具体用法?PHP ContainerBuilder::removeAlias怎么用?PHP ContainerBuilder::removeAlias使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\DependencyInjection\ContainerBuilder
的用法示例。
在下文中一共展示了ContainerBuilder::removeAlias方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadInternal
public function loadInternal(array $config, ContainerBuilder $container)
{
$loader = new XmlFileLoader($container, new FileLocator(array(__DIR__ . '/../Resources/config/')));
$loader->load('services.xml');
// Built-in handlers.
$container->getDefinition('jms_serializer.datetime_handler')->addArgument($config['handlers']['datetime']['default_format'])->addArgument($config['handlers']['datetime']['default_timezone']);
// property naming
$container->getDefinition('jms_serializer.camel_case_naming_strategy')->addArgument($config['property_naming']['separator'])->addArgument($config['property_naming']['lower_case']);
if ($config['property_naming']['enable_cache']) {
$container->getDefinition('jms_serializer.cache_naming_strategy')->addArgument(new Reference((string) $container->getAlias('jms_serializer.naming_strategy')));
$container->setAlias('jms_serializer.naming_strategy', 'jms_serializer.cache_naming_strategy');
}
$bundles = $container->getParameter('kernel.bundles');
// metadata
if ('none' === $config['metadata']['cache']) {
$container->removeAlias('jms_serializer.metadata.cache');
} elseif ('file' === $config['metadata']['cache']) {
$container->getDefinition('jms_serializer.metadata.cache.file_cache')->replaceArgument(0, $config['metadata']['file_cache']['dir']);
$dir = $container->getParameterBag()->resolveValue($config['metadata']['file_cache']['dir']);
if (!file_exists($dir)) {
if (!($rs = @mkdir($dir, 0777, true))) {
throw new RuntimeException(sprintf('Could not create cache directory "%s".', $dir));
}
}
} else {
$container->setAlias('jms_serializer.metadata.cache', new Alias($config['metadata']['cache'], false));
}
if ($config['metadata']['infer_types_from_doctrine_metadata'] && isset($bundles['DoctrineBundle'])) {
$container->setAlias('jms_serializer.metadata_driver', 'jms_serializer.metadata.doctrine_type_driver');
}
$container->getDefinition('jms_serializer.metadata_factory')->replaceArgument(2, $config['metadata']['debug']);
// directories
$directories = array();
if ($config['metadata']['auto_detection']) {
foreach ($bundles as $name => $class) {
$ref = new \ReflectionClass($class);
$directories[$ref->getNamespaceName()] = dirname($ref->getFileName()) . '/Resources/config/serializer';
}
}
foreach ($config['metadata']['directories'] as $directory) {
$directory['path'] = rtrim(str_replace('\\', '/', $directory['path']), '/');
if ('@' === $directory['path'][0]) {
$bundleName = substr($directory['path'], 1, strpos($directory['path'], '/') - 1);
if (!isset($bundles[$bundleName])) {
throw new RuntimeException(sprintf('The bundle "%s" has not been registered with AppKernel. Available bundles: %s', $bundleName, implode(', ', array_keys($bundles))));
}
$ref = new \ReflectionClass($bundles[$bundleName]);
$directory['path'] = dirname($ref->getFileName()) . substr($directory['path'], strlen('@' . $bundleName));
}
$directories[rtrim($directory['namespace_prefix'], '\\')] = rtrim($directory['path'], '\\/');
}
$container->getDefinition('jms_serializer.metadata.file_locator')->replaceArgument(0, $directories);
$container->setParameter('jms_serializer.xml_deserialization_visitor.doctype_whitelist', $config['visitors']['xml']['doctype_whitelist']);
$container->setParameter('jms_serializer.json_serialization_visitor.options', $config['visitors']['json']['options']);
if (!$config['enable_short_alias']) {
$container->removeAlias('serializer');
}
}
示例2: process
public function process(ContainerBuilder $container)
{
// Cache warmer does more harm than good with Drupal.
if ($container->hasDefinition('cache_warmer')) {
$container->removeDefinition('cache_warmer');
}
if ($container->hasAlias('cache_warmer')) {
$container->removeAlias('cache_warmer');
}
// When not working with symfony, we need to provide a file locator
// service of our own instead of the symfony's one
if (!$container->hasDefinition('file_locator') && !$container->hasAlias('file_locator')) {
$container->addDefinitions(['file_locator' => (new Definition())->setClass(CustomFileLocator::class)->addArgument(new Reference('kernel'))]);
} else {
// We are working with fullstack, and our users might have changed
// the global resource directory to somewhere safer than Drupal's
// sites/SITE folder, case in which we must honnor the user's
// configuration
$definition = $container->getDefinition('file_locator');
$definition->setArguments([new Reference('kernel'), $container->getParameter('kernel.root_dir') . '/Resources']);
}
// By registering the framework bundle, we also inherit from Symfony
// default URL generator, which will cause us great pain because of
// Drupal routes will not be known by the framework and throw a few
// exceptions.
if ($container->has('router.default')) {
$container->getDefinition('router.default')->setClass('MakinaCorpus\\Drupal\\Sf\\Routing\\Router');
}
// When NOT in fullstack mode, we need to provide a null implementation
// for the controller resolver service, else the container will be
// unable to spawn the http kernel service
if (!$container->has('controller_resolver')) {
$container->addDefinitions(['controller_resolver' => (new Definition())->setClass('controller_resolver')]);
}
}
示例3: process
public function process(ContainerBuilder $container)
{
foreach ($container->getAliases() as $id => $alias) {
if ($alias->isPublic()) {
continue;
}
$container->removeAlias($id);
}
}
示例4: process
/**
* @param ContainerBuilder $container
*/
public function process(ContainerBuilder $container)
{
$doctrineServiceId = $container->getParameter('lemon_doctrine_registry_service_id');
if ($doctrineServiceId != self::DOCTRINE_ORM) {
$container->removeAlias('lemon_doctrine');
if (!$container->hasDefinition($doctrineServiceId)) {
throw new \RuntimeException(sprintf("Service %s is not configured", $doctrineServiceId));
}
$container->setAlias("lemon_doctrine", $doctrineServiceId);
}
}
示例5: configureMetadata
protected function configureMetadata(array $config, ContainerBuilder $container)
{
// The following configuration has been copied from JMS\SerializerBundle\DependencyInjection\JMSSerializerExtension
if ('none' === $config['metadata']['cache']) {
$container->removeAlias('fsc_hateoas.metadata.cache');
} elseif ('file' === $config['metadata']['cache']) {
$container->getDefinition('fsc_hateoas.metadata.cache.file')->replaceArgument(0, $config['metadata']['file_cache']['dir']);
$dir = $container->getParameterBag()->resolveValue($config['metadata']['file_cache']['dir']);
if (!file_exists($dir) && !($rs = @mkdir($dir, 0777, true))) {
throw new \RuntimeException(sprintf('Could not create cache directory "%s".', $dir));
}
} else {
$container->setAlias('fsc_hateoas.metadata.cache', new Alias($config['metadata']['cache'], false));
}
$container->getDefinition('fsc_hateoas.metadata.base_factory')->replaceArgument(2, $config['metadata']['debug']);
// directories
$directories = array();
$bundles = $container->getParameter('kernel.bundles');
if ($config['metadata']['auto_detection']) {
foreach ($bundles as $name => $class) {
$ref = new \ReflectionClass($class);
$directories[$ref->getNamespaceName()] = dirname($ref->getFileName()) . '/Resources/config/hateoas';
}
}
foreach ($config['metadata']['directories'] as $directory) {
$directory['path'] = rtrim(str_replace('\\', '/', $directory['path']), '/');
if ('@' === $directory['path'][0]) {
$bundleName = substr($directory['path'], 1, strpos($directory['path'], '/') - 1);
if (!isset($bundles[$bundleName])) {
throw new \RuntimeException(sprintf('The bundle "%s" has not been registered with AppKernel. Available bundles: %s', $bundleName, implode(', ', array_keys($bundles))));
}
$ref = new \ReflectionClass($bundles[$bundleName]);
$directory['path'] = dirname($ref->getFileName()) . substr($directory['path'], strlen('@' . $bundleName));
}
$directories[rtrim($directory['namespace_prefix'], '\\')] = rtrim($directory['path'], '\\/');
}
$container->getDefinition('fsc_hateoas.metadata.file_locator')->replaceArgument(0, $directories);
}
示例6: load
public function load(array $configs, ContainerBuilder $container)
{
$config = $this->processConfiguration(new Configuration(), $configs);
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
foreach (array('serializer', 'configuration', 'generator', 'helper', 'twig') as $file) {
$loader->load($file . '.xml');
}
// Based on JMSSerializerBundle
if ('none' === $config['metadata']['cache']) {
$container->removeAlias('hateoas.configuration.metadata.cache');
} elseif ('file' === $config['metadata']['cache']) {
$container->getDefinition('hateoas.configuration.metadata.cache.file_cache')->replaceArgument(0, $config['metadata']['file_cache']['dir']);
$dir = $container->getParameterBag()->resolveValue($config['metadata']['file_cache']['dir']);
if (!file_exists($dir)) {
if (!($rs = @mkdir($dir, 0777, true))) {
throw new \RuntimeException(sprintf('Could not create cache directory "%s".', $dir));
}
}
} else {
$container->setAlias('hateoas.configuration.metadata.cache', new Alias($config['metadata']['cache'], false));
}
$container->getDefinition('hateoas.event_subscriber.json')->replaceArgument(0, new Reference($config['serializer']['json']));
$container->getDefinition('hateoas.event_subscriber.xml')->replaceArgument(0, new Reference($config['serializer']['xml']));
}
示例7: registerCacheStrategy
protected function registerCacheStrategy(ContainerBuilder $container, array $config)
{
if ('none' === $config['metadata']['cache']) {
$container->removeAlias('vich_uploader.metadata.cache');
} elseif ('file' === $config['metadata']['cache']) {
$container->getDefinition('vich_uploader.metadata.cache.file_cache')->replaceArgument(0, $config['metadata']['file_cache']['dir']);
$dir = $container->getParameterBag()->resolveValue($config['metadata']['file_cache']['dir']);
if (!file_exists($dir) && !($rs = @mkdir($dir, 0777, true))) {
throw new \RuntimeException(sprintf('Could not create cache directory "%s".', $dir));
}
} else {
$container->setAlias('vich_uploader.metadata.cache', new Alias($config['metadata']['cache'], false));
}
}
示例8: registerProfilerConfiguration
protected function registerProfilerConfiguration($config, ContainerBuilder $container)
{
if ($config['profiler']) {
if (!$container->hasDefinition('profiler')) {
$loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');
$loader->load('profiling.xml');
$loader->load('collectors.xml');
}
if (isset($config['profiler']['only-exceptions'])) {
$container->setParameter('profiler_listener.only_exceptions', $config['profiler']['only-exceptions']);
} elseif (isset($config['profiler']['only_exceptions'])) {
$container->setParameter('profiler_listener.only_exceptions', $config['profiler']['only_exceptions']);
}
if (isset($config['profiler']['matcher'])) {
if (isset($config['profiler']['matcher']['service'])) {
$container->setAlias('profiler.request_matcher', $config['profiler']['matcher']['service']);
} elseif (isset($config['profiler']['matcher']['_services'])) {
$container->setAlias('profiler.request_matcher', (string) $config['profiler']['matcher']['_services'][0]);
} else {
$definition = $container->register('profiler.request_matcher', 'Symfony\\Component\\HttpFoundation\\RequestMatcher');
if (isset($config['profiler']['matcher']['ip'])) {
$definition->addMethodCall('matchIp', array($config['profiler']['matcher']['ip']));
}
if (isset($config['profiler']['matcher']['path'])) {
$definition->addMethodCall('matchPath', array($config['profiler']['matcher']['path']));
}
}
} else {
$container->removeAlias('profiler.request_matcher');
}
} elseif ($container->hasDefinition('profiler')) {
$container->getDefinition('profiling')->clearTags();
}
}
示例9: removeAlias
public function removeAlias($alias)
{
return $this->delegate->removeAlias($alias);
}
示例10: doAclLoad
protected function doAclLoad(array $config, ContainerBuilder $container)
{
if (!$container->hasDefinition('security.acl')) {
$loader = new XmlFileLoader($container, array(__DIR__ . '/../Resources/config', __DIR__ . '/Resources/config'));
$loader->load('security_acl.xml');
}
if (isset($config['connection'])) {
$container->setAlias('security.acl.dbal.connection', sprintf('doctrine.dbal.%s_connection', $config['connection']));
}
if (isset($config['cache'])) {
$container->setAlias('security.acl.cache', sprintf('security.acl.cache.%s', $config['cache']));
} else {
$container->remove('security.acl.cache.doctrine');
$container->removeAlias('security.acl.cache.doctrine.cache_impl');
}
}