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


PHP ContainerBuilder::getDefinition方法代码示例

本文整理汇总了PHP中Drupal\Core\DependencyInjection\ContainerBuilder::getDefinition方法的典型用法代码示例。如果您正苦于以下问题:PHP ContainerBuilder::getDefinition方法的具体用法?PHP ContainerBuilder::getDefinition怎么用?PHP ContainerBuilder::getDefinition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\Core\DependencyInjection\ContainerBuilder的用法示例。


在下文中一共展示了ContainerBuilder::getDefinition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: alter

 /**
  * {@inheritdoc}
  */
 public function alter(ContainerBuilder $container)
 {
     $definition = $container->getDefinition('asset.resolver');
     $argument = new Reference('cache.null');
     $definition->replaceArgument(5, $argument);
     $definition = $container->getDefinition('library.discovery.collector');
     $argument = new Reference('cache.null');
     $definition->replaceArgument(0, $argument);
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:12,代码来源:UpdateServiceProvider.php

示例2: alter

 /**
  * {@inheritdoc}
  */
 public function alter(ContainerBuilder $container)
 {
     $definition = $container->getDefinition('language_manager');
     $definition->setClass('Drupal\\language\\ConfigurableLanguageManager')->addArgument(new Reference('config.factory'))->addArgument(new Reference('module_handler'))->addArgument(new Reference('language.config_factory_override'))->addArgument(new Reference('request_stack'));
     if ($default_language_values = $this->getDefaultLanguageValues()) {
         $container->setParameter('language.default_values', $default_language_values);
     }
     // For monolingual sites, we explicitly set the default language for the
     // language config override service as there is no language negotiation.
     if (!$this->isMultilingual()) {
         $container->getDefinition('language.config_factory_override')->addMethodCall('setLanguageFromDefault', array(new Reference('language.default')));
     }
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:16,代码来源:LanguageServiceProvider.php

示例3: alter

 /**
  * {@inheritdoc}
  */
 public function alter(ContainerBuilder $container)
 {
     if ($container->has('file.usage')) {
         // Override the class used for the file.usage service.
         $definition = $container->getDefinition('file.usage');
         $definition->setClass('Drupal\\service_provider_test\\TestFileUsage');
     }
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:11,代码来源:ServiceProviderTestServiceProvider.php

示例4: alter

 /**
  * {@inheritdoc}
  */
 public function alter(ContainerBuilder $container)
 {
     $definition = $container->getDefinition('menu.active_trail');
     $definition->setClass('Drupal\\menu_trail_by_path\\MenuTrailByPathActiveTrail');
     $definition->addArgument(new Reference('language_manager'));
     $definition->addArgument(new Reference('path.current'));
     $definition->addArgument(new Reference('path.alias_manager'));
 }
开发者ID:reekris,项目名称:drupal8-menu-trail-by-path,代码行数:11,代码来源:MenuTrailByPathServiceProvider.php

示例5: alter

 /**
  * {@inheritdoc}
  */
 public function alter(ContainerBuilder $container)
 {
     $definition = $container->getDefinition('country_manager');
     // Overrides country_manager class to add additional functionality.
     $definition->setClass('Drupal\\uc_country\\CountryManager');
     // Inject the entity_type.manager service, which is not available in
     // the core country_manager.
     $definition->addArgument(new Reference('entity_type.manager'));
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:12,代码来源:UcCountryServiceProvider.php

示例6: alter

 /**
 * {@inheritdoc}
 */
 public function alter(ContainerBuilder $container)
 {
     $definition = $container->getDefinition('menu.link_tree');
     // Use custom CustomMenuLinkTree class instead of the
     // default MenuLinkTree class.
     $definition->setClass('Drupal\\custom\\CustomMenuLinkTree');
     // Provide an additional argument to the service to add
     // the current_route_match service.
     $definition->addArgument(new Reference('current_route_match'));
 }
开发者ID:willwh,项目名称:menuposition_top,代码行数:13,代码来源:CustomServiceProvider.php

示例7: alter

 /**
  * {@inheritdoc}
  */
 public function alter(ContainerBuilder $container)
 {
     if ($container->has('file.usage')) {
         // Override the class used for the file.usage service.
         $definition = $container->getDefinition('file.usage');
         $definition->setClass('Drupal\\service_provider_test\\TestFileUsage');
     }
     if ($indicator = Settings::get('deployment_identifier')) {
         $container->setParameter('container_rebuild_indicator', $indicator);
     }
 }
开发者ID:jeyram,项目名称:camp-gdl,代码行数:14,代码来源:ServiceProviderTestServiceProvider.php

示例8: alter

 /**
  * {@inheritdoc}
  */
 public function alter(ContainerBuilder $container)
 {
     // Ensure that URLs generated for the home and admin pages don't have
     // 'update.php' in them.
     $request = Request::createFromGlobals();
     $definition = $container->getDefinition('url_generator');
     $definition->addMethodCall('setBasePath', array(str_replace('/core', '', $request->getBasePath()) . '/'));
     // We need to set the script path to an empty string since the value
     // determined by \Drupal\Core\Routing\UrlGenerator::setRequest() is invalid
     // once '/core' has been removed from the base path.
     $definition->addMethodCall('setScriptPath', array(''));
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:15,代码来源:UpdateServiceProvider.php

示例9: addLightbox

 /**
  * @param \Drupal\Core\DependencyInjection\ContainerBuilder $container
  * @param $id
  * @param $title
  */
 protected function addLightbox(ContainerBuilder $container, $id, $title)
 {
     $definition = $container->getDefinition($id);
     $tags = $definition->getTags();
     foreach ($tags as $delta => &$tag) {
         if ($delta === 'render.main_content_renderer') {
             foreach ($tag as &$attribute) {
                 $attribute['ng_lightbox'] = $title;
             }
         }
     }
     $definition->setTags($tags);
 }
开发者ID:318io,项目名称:318-io,代码行数:18,代码来源:NgLightboxServiceProvider.php

示例10: addRouteProvider

 /**
  * Add the on demand rebuild route provider service.
  *
  * @param \Drupal\Core\DependencyInjection\ContainerBuilder $container
  */
 public static function addRouteProvider(ContainerBuilder $container)
 {
     foreach (['router.route_provider' => 'RouteProvider'] as $original_id => $class) {
         // While $container->get() does a recursive resolve, getDefinition() does
         // not, so do it ourselves.
         for ($id = $original_id; $container->hasAlias($id); $id = (string) $container->getAlias($id)) {
         }
         $definition = $container->getDefinition($id);
         $definition->clearTag('needs_destruction');
         $container->setDefinition("simpletest.{$original_id}", $definition);
         $container->setDefinition($id, new Definition('Drupal\\simpletest\\' . $class));
     }
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:18,代码来源:TestServiceProvider.php

示例11: testParseDefinitionsWithProvider

    public function testParseDefinitionsWithProvider()
    {
        $yml = <<<YAML
services:
  example_service:
    class: \\Drupal\\Core\\ExampleClass
YAML;
        vfsStream::setup('drupal', NULL, ['modules/example/example.yml' => $yml]);
        $builder = new ContainerBuilder();
        $yaml_file_loader = new YamlFileLoader($builder);
        $yaml_file_loader->load('vfs://drupal/modules/example/example.yml');
        $this->assertEquals(['_provider' => [['provider' => 'example']]], $builder->getDefinition('example_service')->getTags());
    }
开发者ID:eigentor,项目名称:tommiblog,代码行数:13,代码来源:YamlFileLoaderTest.php

示例12: 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

示例13: alter

 public function alter(ContainerBuilder $container)
 {
     // Override the password_migrate class with a new class.
     try {
         $definition = $container->getDefinition('password_migrate');
         $definition->setClass('Drupal\\multiversion\\MigratePassword');
     } catch (InvalidArgumentException $e) {
         // Do nothing, migrate module is not installed.
     }
     $renderer_config = $container->getParameter('renderer.config');
     $renderer_config['required_cache_contexts'][] = 'workspace';
     $container->setParameter('renderer.config', $renderer_config);
     // Switch the menu tree storage to our own that respect Workspace cache
     // contexts.
     $definition = $container->getDefinition('menu.tree_storage');
     $definition->setClass('Drupal\\multiversion\\MenuTreeStorage');
     // Override the comment.statistics class with a new class.
     try {
         $definition = $container->getDefinition('comment.statistics');
         $definition->setClass('Drupal\\multiversion\\CommentStatistics');
     } catch (InvalidArgumentException $e) {
         // Do nothing, comment module is not installed.
     }
 }
开发者ID:sedurzu,项目名称:ildeposito8,代码行数:24,代码来源:MultiversionServiceProvider.php

示例14: alter

 /**
  * {@inheritdoc}
  */
 public function alter(ContainerBuilder $container)
 {
     // Disable configuration overrides.
     // ConfigFactory would to try to load language overrides and InstallStorage
     // throws an exception upon trying to load a non-existing file.
     $container->get('config.factory')->setOverrideState(FALSE);
     // No service may persist when the early installer kernel is rebooted into
     // the production environment.
     // @todo The DrupalKernel reboot performed by drupal_install_system() is
     //   actually not a "regular" reboot (like ModuleHandler::install()), so
     //   services are not actually persisted.
     foreach ($container->findTaggedServiceIds('persist') as $id => $tags) {
         $definition = $container->getDefinition($id);
         $definition->clearTag('persist');
     }
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:19,代码来源:InstallerServiceProvider.php

示例15: alter

 /**
  * {@inheritdoc}
  */
 public function alter(ContainerBuilder $container)
 {
     // Disable Twig cache (php storage does not exist yet).
     $twig_config = $container->getParameter('twig.config');
     $twig_config['cache'] = FALSE;
     $container->setParameter('twig.config', $twig_config);
     // No service may persist when the early installer kernel is rebooted into
     // the production environment.
     // @todo The DrupalKernel reboot performed by drupal_install_system() is
     //   actually not a "regular" reboot (like ModuleHandler::install()), so
     //   services are not actually persisted.
     foreach ($container->findTaggedServiceIds('persist') as $id => $tags) {
         $definition = $container->getDefinition($id);
         $definition->clearTag('persist');
     }
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:19,代码来源:InstallerServiceProvider.php


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