本文整理汇总了PHP中Symfony\Component\DependencyInjection\ContainerBuilder::removeDefinition方法的典型用法代码示例。如果您正苦于以下问题:PHP ContainerBuilder::removeDefinition方法的具体用法?PHP ContainerBuilder::removeDefinition怎么用?PHP ContainerBuilder::removeDefinition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\DependencyInjection\ContainerBuilder
的用法示例。
在下文中一共展示了ContainerBuilder::removeDefinition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$processor = new Processor();
$config = $processor->processConfiguration($configuration, $configs);
$container->setParameter('deuzu_request_collector', $config);
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.yml');
// @moulox
$logger = false;
$mailer = false;
$persister = false;
foreach ($config['collectors'] as $collectorName => $collector) {
if ($collector['logger']['enabled']) {
$logger = true;
}
if ($collector['mailer']['enabled']) {
$mailer = true;
}
if ($collector['persister']['enabled']) {
$persister = true;
}
}
if (!$logger) {
$container->removeDefinition('deuzu.request_collector.collector.logger');
}
if (!$persister) {
$container->removeDefinition('deuzu.request_collector.collector.persister');
}
if (!$mailer) {
$container->removeDefinition('deuzu.request_collector.collector.mailer');
}
}
示例2: process
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
$typeIdx = array();
foreach ($container->findTaggedServiceIds('form.type') as $id => $tags) {
$typeIdx[] = $id;
}
$typeExtensionIdx = array();
foreach ($container->findTaggedServiceIds('form.type_extension') as $id => $tag) {
$typeExtensionIdx[] = $id;
}
$container->setParameter('sonata.core.form.types', $typeIdx);
$container->setParameter('sonata.core.form.type_extensions', $typeExtensionIdx);
// nothing to do
if (!$container->hasDefinition('sonata.core.form.extension.dependency')) {
return;
}
// get factories
$original = $container->getDefinition('form.extension');
$factory = $container->getDefinition('sonata.core.form.extension.dependency');
$factory->replaceArgument(1, $original->getArgument(1));
$factory->replaceArgument(2, $original->getArgument(2));
$factory->replaceArgument(3, $original->getArgument(3));
$container->removeDefinition('form.extension');
$container->removeDefinition('sonata.core.form.extension.dependency');
$container->setDefinition('form.extension', $factory);
}
示例3: process
public function process(ContainerBuilder $container)
{
if ($container->has('fos_rest.serializer')) {
$class = $container->getParameterBag()->resolveValue($container->findDefinition('fos_rest.serializer')->getClass());
if (!is_subclass_of($class, 'FOS\\RestBundle\\Serializer\\Serializer')) {
throw new \InvalidArgumentException(sprintf('"fos_rest.serializer" must implement FOS\\RestBundle\\Serializer\\Serializer (instance of "%s" given).', $class));
}
return;
}
if (!$container->has('serializer') && !$container->has('jms_serializer.serializer')) {
throw new \InvalidArgumentException('Neither a service called "jms_serializer.serializer" nor "serializer" is available and no serializer is explicitly configured. You must either enable the JMSSerializerBundle, enable the FrameworkBundle serializer or configure a custom serializer.');
}
if ($container->has('serializer')) {
$class = $container->getParameterBag()->resolveValue($container->findDefinition('serializer')->getClass());
if (is_subclass_of($class, 'Symfony\\Component\\Serializer\\SerializerInterface')) {
$container->setAlias('fos_rest.serializer', 'fos_rest.serializer.symfony');
$container->removeDefinition('fos_rest.serializer.exception_wrapper_serialize_handler');
} elseif (is_subclass_of($class, 'JMS\\Serializer\\SerializerInterface')) {
$container->setAlias('fos_rest.serializer', 'fos_rest.serializer.jms');
} elseif (is_subclass_of($class, 'FOS\\RestBundle\\Serializer\\Serializer')) {
$container->setAlias('fos_rest.serializer', 'serializer');
} else {
throw new \InvalidArgumentException(sprintf('"fos_rest.serializer" must implement FOS\\RestBundle\\Serializer\\Serializer (instance of "%s" given).', $class));
}
return;
} else {
$container->removeDefinition('fos_rest.serializer.exception_wrapper_normalizer');
}
if ($container->has('jms_serializer.serializer')) {
$container->setAlias('fos_rest.serializer', 'fos_rest.serializer.jms');
} else {
$container->removeDefinition('fos_rest.serializer.exception_wrapper_serialize_handler');
}
}
示例4: process
/**
* You can modify the container here before it is dumped to PHP code.
*
* @param ContainerBuilder $container
*
* @api
*/
public function process(ContainerBuilder $container)
{
$config = $container->getParameter(ElastificationPhpClientExtension::PARAMETER_CONFIG_KEY);
if (true === $config['profiler_enabled']) {
$clientAlias = $container->getAlias(ElastificationPhpClientExtension::ALIAS_CLIENT);
$profilerDef = $container->getDefinition(ElastificationPhpClientExtension::SERVICE_CLIENT_PROFILER_KEY);
$profilerDef->replaceArgument(0, new Reference($clientAlias->__toString()));
$dataCollectorDef = $container->getDefinition('elastification_php_client.datacollector');
$dataCollectorDef->addMethodCall('setConfig', array($config));
$container->setAlias(ElastificationPhpClientExtension::ALIAS_CLIENT, ElastificationPhpClientExtension::SERVICE_CLIENT_PROFILER_KEY);
} else {
if ($container->hasDefinition('profiler')) {
$sfProfilerDef = $container->getDefinition('profiler');
$sfProfilerMethodCalls = $sfProfilerDef->getMethodCalls();
foreach ($sfProfilerMethodCalls as $sfProfilerMethodCallsIndex => $sfProfilerMethodCall) {
if (isset($sfProfilerMethodCall[1][0]) && 'elastification_php_client.datacollector' == (string) $sfProfilerMethodCall[1][0]) {
unset($sfProfilerMethodCalls[$sfProfilerMethodCallsIndex]);
}
}
$sfProfilerDef->setMethodCalls($sfProfilerMethodCalls);
}
$container->removeDefinition(ElastificationPhpClientExtension::SERVICE_CLIENT_PROFILER_KEY);
$container->removeDefinition('elastification_php_client.datacollector');
}
}
示例5: process
public function process(ContainerBuilder $container)
{
if ($container->hasDefinition('assetic.filter.closure.jar') && $container->hasParameter('assetic.filter.closure.jar') && $container->getParameterBag()->resolveValue($container->getParameter('assetic.filter.closure.jar'))) {
$container->removeDefinition('assetic.filter.closure.api');
} elseif ($container->hasDefinition('assetic.filter.closure.api')) {
$container->removeDefinition('assetic.filter.closure.jar');
}
}
示例6: process
public function process(ContainerBuilder $container)
{
if ($container->hasDefinition('session')) {
return;
}
$container->removeDefinition('lunetics_locale.session_guesser');
$container->removeDefinition('lunetics_locale.locale_session');
}
示例7: process
public function process(ContainerBuilder $container)
{
if (false === $container->hasDefinition('security.csrf.token_manager')) {
$container->removeDefinition('dunglas_angular_csrf.validation_listener');
$container->removeDefinition('dunglas_angular_csrf.form.extension.disable_csrf');
$container->removeDefinition('dunglas_angular_csrf.cookie_listener');
$container->removeDefinition('dunglas_angular_csrf.token_manager');
}
}
示例8: removeCacheRestorer
/**
* Removes cache restore definition if unnecessary.
*
* @param array $config
* @param ContainerBuilder $container
*/
protected function removeCacheRestorer(array $config, ContainerBuilder $container)
{
if (!$config['cache_restore']) {
$container->removeDefinition('yahoo_japan_config_cache.cache_saver');
$container->removeDefinition('yahoo_japan_config_cache.cache_restorer');
$container->removeDefinition('yahoo_japan_config_cache.cache_cleanup');
}
return $this;
}
示例9: process
public function process(ContainerBuilder $container)
{
if ($container->has('fos_rest.exception_listener') && $container->has('twig.exception_listener')) {
$container->removeDefinition('twig.exception_listener');
}
if (!$container->has('templating.engine.twig')) {
$container->removeDefinition('fos_rest.exception.twig_controller');
}
}
示例10: process
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
if (!$container->hasDefinition('templating.engine.php')) {
$container->removeDefinition('ivory_ck_editor.templating.helper');
}
if (!$container->hasDefinition('twig')) {
$container->removeDefinition('ivory_ck_editor.twig_extension');
}
}
示例11: load
/**
* Loads the configuration.
*
* @param array $configs An array of configuration settings
* @param ContainerBuilder $container A ContainerBuilder instance
*/
public function load(array $configs, ContainerBuilder $container)
{
$parameterBag = $container->getParameterBag();
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('assetic.xml');
$loader->load('templating_twig.xml');
$loader->load('templating_php.xml');
$config = self::processConfigs($configs, $container->getParameter('kernel.debug'), array_keys($container->getParameter('kernel.bundles')));
$container->setParameter('assetic.debug', $config['debug']);
$container->setParameter('assetic.use_controller', $config['use_controller']);
$container->setParameter('assetic.read_from', $config['read_from']);
$container->setParameter('assetic.write_to', $config['write_to']);
$container->setParameter('assetic.java.bin', $config['java']);
$container->setParameter('assetic.node.bin', $config['node']);
$container->setParameter('assetic.sass.bin', $config['sass']);
// register filters
foreach ($config['filters'] as $name => $filter) {
if (isset($filter['resource'])) {
$loader->load($parameterBag->resolveValue($filter['resource']));
unset($filter['resource']);
} else {
$loader->load('filters/'.$name.'.xml');
}
if (isset($filter['file'])) {
$container->getDefinition('assetic.filter.'.$name)->setFile($filter['file']);
unset($filter['file']);
}
foreach ($filter as $key => $value) {
$container->setParameter('assetic.filter.'.$name.'.'.$key, $value);
}
}
// twig functions
$container->getDefinition('assetic.twig_extension')->replaceArgument(2, $config['twig']['functions']);
// choose dynamic or static
if ($parameterBag->resolveValue($parameterBag->get('assetic.use_controller'))) {
$loader->load('controller.xml');
$container->getDefinition('assetic.helper.dynamic')->addTag('templating.helper', array('alias' => 'assetic'));
$container->removeDefinition('assetic.helper.static');
} else {
$loader->load('asset_writer.xml');
$container->getDefinition('assetic.helper.static')->addTag('templating.helper', array('alias' => 'assetic'));
$container->removeDefinition('assetic.helper.dynamic');
}
// register config resources
self::registerFormulaResources($container, $parameterBag->resolveValue($config['bundles']));
}
示例12: load
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$configDir = __DIR__ . '/../Resources/config';
$loader = new Loader\YamlFileLoader($container, new FileLocator($configDir));
$loader->load('services.yml');
$bundles = $container->getParameter('kernel.bundles');
if (!isset($bundles['DoctrineBundle'])) {
$container->removeDefinition('rafrsr_datepicker_type_guesser');
$container->removeDefinition('rafrsr_switchery_type_guesser');
}
}
示例13: process
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
$definition = $container->getDefinition('sonata.core.model.adapter.chain');
if ($container->has('doctrine')) {
$definition->addMethodCall('addAdapter', array(new Reference('sonata.core.model.adapter.doctrine_orm')));
} else {
$container->removeDefinition('sonata.core.model.adapter.doctrine_orm');
}
if ($container->has('doctrine_phpcr')) {
$definition->addMethodCall('addAdapter', array(new Reference('sonata.core.model.adapter.doctrine_phpcr')));
} else {
$container->removeDefinition('sonata.core.model.adapter.doctrine_phpcr');
}
}
示例14: load
/**
* {@inheritDoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.xml');
if (!in_array('FOS\\UserBundle\\FOSUserBundle', $container->getParameter('kernel.bundles'))) {
$container->removeDefinition('hatimeria_admin.user.form.extensions_collector');
$container->removeDefinition('hatimeria_admin.user.form.handler');
} else {
$fos_class = $container->getParameterBag()->resolveValue($container->getParameterBag()->get('fos_user.model.user.class'));
$builder = $container->getDefinition('hatimeria_admin.user.form.handler');
$builder->replaceArgument(2, new Reference('fos_user.user_manager'));
$builder->replaceArgument(3, $fos_class);
}
}
示例15: load
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configDir = __DIR__ . '/../Resources/config';
$processor = new Processor();
$config = $processor->processConfiguration(new Configuration($this->getAlias()), $configs);
$container->setParameter($this->getAlias(), $config);
$loader = new YamlFileLoader($container, new FileLocator($configDir));
$loader->load('services.yml');
$container->setParameter($this->getAlias() . '.mailerloaded', $config['enabled']);
if (!$config['alphasms_key']) {
$container->removeDefinition('werkint_notification.handler.sms');
$container->removeDefinition('werkint_notification.bridge.alphasms');
}
}