本文整理汇总了PHP中Drupal\Core\DependencyInjection\ContainerBuilder::hasParameter方法的典型用法代码示例。如果您正苦于以下问题:PHP ContainerBuilder::hasParameter方法的具体用法?PHP ContainerBuilder::hasParameter怎么用?PHP ContainerBuilder::hasParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\DependencyInjection\ContainerBuilder
的用法示例。
在下文中一共展示了ContainerBuilder::hasParameter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: alter
/**
* {@inheritdoc}
*/
public function alter(ContainerBuilder $container)
{
if ($container->has('config.factory')) {
// The configuration factory depends on the cache factory, but that
// depends on the 'cache_default_bin_backends' parameter that has not yet
// been set by \Drupal\Core\Cache\ListCacheBinsPass::process() at this
// point.
$parameter_name = 'cache_default_bin_backends';
if (!$container->hasParameter($parameter_name)) {
$container->setParameter($parameter_name, []);
}
/** @var \Drupal\Core\Config\ConfigFactoryInterface $config_factory */
$config_factory = $container->get('config.factory');
$config = $config_factory->get('libraries.settings');
if (!$config->isNew()) {
// Set the local definition path.
$container->getDefinition('libraries.definition.discovery.local')->replaceArgument(1, $config->get('definition.local.path'));
// Set the remote definition URL. Note that this is set even if
// the remote discovery is not enabled below in case the
// 'libraries.definition.discovery.remote' service is used explicitly.
$container->getDefinition('libraries.definition.discovery.remote')->replaceArgument(2, $config->get('definition.remote.url'));
// Because it is less convenient to remove a method call than to add
// one, the remote discovery is not registered in libraries.services.yml
// and instead added here, even though the 'definition.remote.enable'
// configuration value is TRUE by default.
if ($config->get('definition.remote.enable')) {
// Add the remote discovery to the list of chained discoveries.
$container->getDefinition('libraries.definition.discovery')->addMethodCall('addDiscovery', [new Reference('libraries.definition.discovery.remote')]);
}
}
// At this point the event dispatcher has not yet been populated with
// event subscribers by RegisterEventSubscribersPass::process() but has
// already bin injected in the configuration factory. Reset those services
// accordingly.
$container->set('event_dispatcher', NULL);
$container->set('config.factory', NULL);
}
}