本文整理汇总了PHP中Symfony\Component\DependencyInjection\ContainerBuilder::remove方法的典型用法代码示例。如果您正苦于以下问题:PHP ContainerBuilder::remove方法的具体用法?PHP ContainerBuilder::remove怎么用?PHP ContainerBuilder::remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\DependencyInjection\ContainerBuilder
的用法示例。
在下文中一共展示了ContainerBuilder::remove方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
public function process(ContainerBuilder $container)
{
if ($container->hasDefinition('assetic.filter.closure.jar') && $container->getParameterBag()->resolveValue($container->getParameter('assetic.filter.closure.jar'))) {
$container->remove('assetic.filter.closure.api');
} elseif ($container->hasDefinition('assetic.filter.closure.api')) {
$container->remove('assetic.filter.closure.jar');
}
}
示例2: createRoleHierarchy
protected function createRoleHierarchy($config, ContainerBuilder $container)
{
$roles = array();
if (isset($config['role_hierarchy'])) {
$roles = $config['role_hierarchy'];
} elseif (isset($config['role-hierarchy'])) {
$roles = $config['role-hierarchy'];
}
if (isset($roles['role']) && is_int(key($roles['role']))) {
$roles = $roles['role'];
}
$hierarchy = array();
foreach ($roles as $id => $role) {
if (is_array($role) && isset($role['id'])) {
$id = $role['id'];
}
$value = $role;
if (is_array($role) && isset($role['value'])) {
$value = $role['value'];
}
$hierarchy[$id] = is_array($value) ? $value : preg_split('/\\s*,\\s*/', $value);
}
$container->setParameter('security.role_hierarchy.roles', $hierarchy);
$container->remove('security.access.simple_role_voter');
$container->getDefinition('security.access.role_hierarchy_voter')->addTag('security.voter');
}
示例3: 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);
}
}
// choose dynamic or static
if ($parameterBag->resolveValue($parameterBag->get('assetic.use_controller'))) {
$loader->load('controller.xml');
$container->setParameter('assetic.twig_extension.class', '%assetic.twig_extension.dynamic.class%');
$container->getDefinition('assetic.helper.dynamic')->addTag('templating.helper', array('alias' => 'assetic'));
$container->remove('assetic.helper.static');
} else {
$loader->load('asset_writer.xml');
$container->setParameter('assetic.twig_extension.class', '%assetic.twig_extension.static.class%');
$container->getDefinition('assetic.helper.static')->addTag('templating.helper', array('alias' => 'assetic'));
$container->remove('assetic.helper.dynamic');
}
// register config resources
self::registerFormulaResources($container, $parameterBag->resolveValue($config['bundles']));
}
示例4: process
/**
* Removes abstract definitions from the ContainerBuilder
*
* @param ContainerBuilder $container
*/
public function process(ContainerBuilder $container)
{
foreach ($container->getDefinitions() as $id => $definition) {
if ($definition->isAbstract()) {
$container->remove($id);
}
}
}
示例5: process
public function process(ContainerBuilder $container)
{
if (!$container->hasDefinition('assetic.asset_manager')) {
return;
}
$engines = $container->getParameterBag()->resolveValue($container->getParameter('templating.engines'));
if (!in_array('twig', $engines)) {
foreach ($container->findTaggedServiceIds('assetic.templating.twig') as $id => $attr) {
$container->remove($id);
}
}
if (!in_array('php', $engines)) {
foreach ($container->findTaggedServiceIds('assetic.templating.php') as $id => $attr) {
$container->remove($id);
}
}
}
示例6: process
/**
* Processes the ContainerBuilder to remove unused definitions.
*
* @param ContainerBuilder $container
* @return void
*/
public function process(ContainerBuilder $container)
{
$compiler = $container->getCompiler();
$formatter = $compiler->getLoggingFormatter();
$graph = $compiler->getServiceReferenceGraph();
$hasChanged = false;
foreach ($container->getDefinitions() as $id => $definition) {
if ($definition->isPublic()) {
continue;
}
if ($graph->hasNode($id)) {
$edges = $graph->getNode($id)->getInEdges();
$referencingAliases = array();
$sourceIds = array();
foreach ($edges as $edge) {
$node = $edge->getSourceNode();
$sourceIds[] = $node->getId();
if ($node->isAlias()) {
$referencingAlias[] = $node->getValue();
}
}
$isReferenced = count(array_unique($sourceIds)) - count($referencingAliases) > 0;
} else {
$referencingAliases = array();
$isReferenced = false;
}
if (1 === count($referencingAliases) && false === $isReferenced) {
$container->setDefinition((string) reset($referencingAliases), $definition);
$definition->setPublic(true);
$container->remove($id);
$compiler->addLogMessage($formatter->formatRemoveService($this, $id, 'replaces alias ' . reset($referencingAliases)));
} else {
if (0 === count($referencingAliases) && false === $isReferenced) {
$container->remove($id);
$compiler->addLogMessage($formatter->formatRemoveService($this, $id, 'unused'));
$hasChanged = true;
}
}
}
if ($hasChanged) {
$this->repeatedPass->setRepeat();
}
}
示例7: process
/**
* Removes abstract definitions from the ContainerBuilder
*
* @param ContainerBuilder $container
*/
public function process(ContainerBuilder $container)
{
$compiler = $container->getCompiler();
$formatter = $compiler->getLoggingFormatter();
foreach ($container->getDefinitions() as $id => $definition) {
if ($definition->isAbstract()) {
$container->remove($id);
$compiler->addLogMessage($formatter->formatRemoveService($this, $id, 'abstract'));
}
}
}
示例8: process
public function process(ContainerBuilder $container)
{
if (!$container->hasDefinition('assetic.asset_manager')) {
return;
}
$am = $container->getDefinition('assetic.asset_manager');
$engines = $container->getParameterBag()->resolveValue($container->getParameter('templating.engines'));
if (in_array('twig', $engines)) {
$am->addMethodCall('addCacheFile', array('%kernel.cache_dir%/assetic_twig_assets.php'));
} else {
foreach ($container->findTaggedServiceIds('assetic.templating.twig') as $id => $attr) {
$container->remove($id);
}
}
if (in_array('php', $engines)) {
// $am->addMethodCall('addCacheFile', array('%kernel.cache_dir%/assetic_php_assets.php'));
} else {
foreach ($container->findTaggedServiceIds('assetic.templating.php') as $id => $attr) {
$container->remove($id);
}
}
}
示例9: load
public function load(array $configs, ContainerBuilder $container)
{
$processor = new Processor();
$config = $processor->process($this->getConfigTree(), $configs);
$loader = new XmlFileLoader($container, new FileLocator(array(__DIR__ . '/../Resources/config/')));
$loader->load('services.xml');
$container->setParameter('security.extra.secure_all_services', $config['secure_all_services']);
if (!$config['secure_controllers']) {
$container->remove('security.extra.controller_listener');
$this->addClassesToCompile(array('JMS\\SecurityExtraBundle\\Security\\Authorization\\Interception\\MethodInvocation', 'JMS\\SecurityExtraBundle\\Security\\Authorization\\Interception\\MethodSecurityInterceptor', 'JMS\\SecurityExtraBundle\\Security\\Authorization\\AfterInvocation\\AfterInvocationManager', 'JMS\\SecurityExtraBundle\\Security\\Authorization\\AfterInvocation\\AfterInvocationManagerInterface', 'JMS\\SecurityExtraBundle\\Security\\Authorization\\AfterInvocation\\AfterInvocationProviderInterface', 'JMS\\SecurityExtraBundle\\Security\\Authorization\\RunAsManager', 'JMS\\SecurityExtraBundle\\Security\\Authorization\\RunAsManagerInterface'));
} else {
$this->addClassesToCompile(array('JMS\\SecurityExtraBundle\\Controller\\ControllerListener', 'JMS\\SecurityExtraBundle\\Mapping\\Driver\\AnnotationParser', 'JMS\\SecurityExtraBundle\\Mapping\\Driver\\AnnotationConverter', 'JMS\\SecurityExtraBundle\\Security\\Authorization\\Interception\\MethodInvocation'));
}
if ($config['enable_iddqd_attribute']) {
$container->getDefinition('security.extra.iddqd_voter')->addTag('security.voter');
// FIXME: Also add an iddqd after invocation provider
}
}
示例10: process
public function process(ContainerBuilder $container)
{
foreach ($container->getAliases() as $id => $alias) {
$aliasId = (string) $alias;
$definition = $container->getDefinition($aliasId = (string) $alias);
if ($definition->isPublic()) {
continue;
}
$definition->setPublic(true);
$container->setDefinition($id, $definition);
$container->remove($aliasId);
$this->updateReferences($container, $aliasId, $id);
// we have to restart the process due to concurrent modification of
// the container
$this->process($container);
break;
}
}
示例11: load
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.xml');
$loader->load('twig.xml');
$loader->load('events.xml');
$loader->load('configuration_manager.xml');
foreach ($config as $key => $value) {
$container->setParameter('spliced_cms.' . $key, $value);
}
$bundles = $container->getParameter('kernel.bundles');
if (!isset($bundles["SplicedAdminThemeBundle"])) {
$container->remove('spliced_cms.listener.admin_main_menu');
}
$container->setAlias('commerce.user_provider', $config['user_provider']);
}
示例12: 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');
}
}
示例13: createRoleHierarchy
/**
* Loads the web configuration.
*
* @param array $config An array of configuration settings
* @param ContainerBuilder $container A ContainerBuilder instance
*/
private function createRoleHierarchy($config, ContainerBuilder $container)
{
if (!isset($config['role_hierarchy'])) {
$container->remove('security.access.role_hierarchy_voter');
return;
}
$container->setParameter('security.role_hierarchy.roles', $config['role_hierarchy']);
$container->remove('security.access.simple_role_voter');
}
示例14: createRoleHierarchy
/**
* Loads the web configuration.
*
* @param array $config An array of configuration settings
* @param ContainerBuilder $container A ContainerBuilder instance
*/
protected function createRoleHierarchy($config, ContainerBuilder $container)
{
if (!isset($config['role_hierarchy'])) {
return;
}
$container->setParameter('security.role_hierarchy.roles', $config['role_hierarchy']);
$container->remove('security.access.simple_role_voter');
$container->getDefinition('security.access.role_hierarchy_voter')->addTag('security.voter');
}