当前位置: 首页>>代码示例>>PHP>>正文


PHP ContainerBuilder::hasParameter方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:hugronaphor,项目名称:cornel,代码行数:41,代码来源:LibrariesServiceProvider.php


注:本文中的Drupal\Core\DependencyInjection\ContainerBuilder::hasParameter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。