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


PHP ContainerBuilder::hasDefinition方法代码示例

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


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

示例1: register

 /**
  * {@inheritdoc}
  */
 public function register(ContainerBuilder $container)
 {
     $container->addCompilerPass(new StoragePass());
     if (FALSE !== $container->hasDefinition('profiler')) {
         $container->register('webprofiler.xhprof', 'Drupal\\xhprof\\DataCollector\\XHProfDataCollector')->addArgument(new Reference('xhprof.profiler'))->addTag('data_collector', array('template' => '@xhprof/Collector/xhprof.html.twig', 'id' => 'xhprof', 'title' => 'XHProf', 'priority' => 50));
     }
 }
开发者ID:shahinam,项目名称:drupal8devel,代码行数:10,代码来源:XhprofServiceProvider.php

示例2: containerBuild

 /**
  * Sets up the base service container for this test.
  *
  * Extend this method in your test to register additional service overrides
  * that need to persist a DrupalKernel reboot. This method is called whenever
  * the kernel is rebuilt.
  *
  * @see \Drupal\simpletest\KernelTestBase::setUp()
  * @see \Drupal\simpletest\KernelTestBase::enableModules()
  * @see \Drupal\simpletest\KernelTestBase::disableModules()
  */
 public function containerBuild(ContainerBuilder $container)
 {
     // Keep the container object around for tests.
     $this->container = $container;
     // Set the default language on the minimal container.
     $this->container->setParameter('language.default_values', $this->defaultLanguageData());
     $container->register('lock', 'Drupal\\Core\\Lock\\NullLockBackend');
     $container->register('cache_factory', 'Drupal\\Core\\Cache\\MemoryBackendFactory');
     $container->register('config.storage', 'Drupal\\Core\\Config\\DatabaseStorage')->addArgument(Database::getConnection())->addArgument('config');
     if ($this->strictConfigSchema) {
         $container->register('simpletest.config_schema_checker', 'Drupal\\Core\\Config\\Testing\\ConfigSchemaChecker')->addArgument(new Reference('config.typed'))->addArgument($this->getConfigSchemaExclusions())->addTag('event_subscriber');
     }
     $keyvalue_options = $container->getParameter('factory.keyvalue') ?: array();
     $keyvalue_options['default'] = 'keyvalue.memory';
     $container->setParameter('factory.keyvalue', $keyvalue_options);
     $container->set('keyvalue.memory', $this->keyValueFactory);
     if (!$container->has('keyvalue')) {
         // TestBase::setUp puts a completely empty container in
         // $this->container which is somewhat the mirror of the empty
         // environment being set up. Unit tests need not to waste time with
         // getting a container set up for them. Drupal Unit Tests might just get
         // away with a simple container holding the absolute bare minimum. When
         // a kernel is overridden then there's no need to re-register the keyvalue
         // service but when a test is happy with the superminimal container put
         // together here, it still might a keyvalue storage for anything using
         // \Drupal::state() -- that's why a memory service was added in the first
         // place.
         $container->register('settings', 'Drupal\\Core\\Site\\Settings')->setFactoryClass('Drupal\\Core\\Site\\Settings')->setFactoryMethod('getInstance');
         $container->register('keyvalue', 'Drupal\\Core\\KeyValueStore\\KeyValueFactory')->addArgument(new Reference('service_container'))->addArgument(new Parameter('factory.keyvalue'));
         $container->register('state', 'Drupal\\Core\\State\\State')->addArgument(new Reference('keyvalue'));
     }
     if ($container->hasDefinition('path_processor_alias')) {
         // Prevent the alias-based path processor, which requires a url_alias db
         // table, from being registered to the path processor manager. We do this
         // by removing the tags that the compiler pass looks for. This means the
         // url generator can safely be used within tests.
         $definition = $container->getDefinition('path_processor_alias');
         $definition->clearTag('path_processor_inbound')->clearTag('path_processor_outbound');
     }
     if ($container->hasDefinition('password')) {
         $container->getDefinition('password')->setArguments(array(1));
     }
     // Register the stream wrapper manager.
     $container->register('stream_wrapper_manager', 'Drupal\\Core\\StreamWrapper\\StreamWrapperManager')->addArgument(new Reference('module_handler'))->addMethodCall('setContainer', array(new Reference('service_container')));
     $request = Request::create('/');
     $container->get('request_stack')->push($request);
 }
开发者ID:isramv,项目名称:camp-gdl,代码行数:58,代码来源:KernelTestBase.php

示例3: register

 /**
  * Registers test-specific services.
  *
  * Extend this method in your test to register additional services. This
  * method is called whenever the kernel is rebuilt.
  *
  * @param \Drupal\Core\DependencyInjection\ContainerBuilder $container
  *   The service container to enhance.
  *
  * @see \Drupal\Tests\KernelTestBase::bootKernel()
  */
 public function register(ContainerBuilder $container)
 {
     // Keep the container object around for tests.
     $this->container = $container;
     $container->register('flood', 'Drupal\\Core\\Flood\\MemoryBackend')->addArgument(new Reference('request_stack'));
     $container->register('lock', 'Drupal\\Core\\Lock\\NullLockBackend');
     $container->register('cache_factory', 'Drupal\\Core\\Cache\\MemoryBackendFactory');
     $container->register('keyvalue.memory', 'Drupal\\Core\\KeyValueStore\\KeyValueMemoryFactory')->addTag('persist');
     $container->setAlias('keyvalue', 'keyvalue.memory');
     // Set the default language on the minimal container.
     $container->setParameter('language.default_values', Language::$defaultValues);
     if ($this->strictConfigSchema) {
         $container->register('simpletest.config_schema_checker', 'Drupal\\Core\\Config\\Testing\\ConfigSchemaChecker')->addArgument(new Reference('config.typed'))->addArgument($this->getConfigSchemaExclusions())->addTag('event_subscriber');
     }
     if ($container->hasDefinition('path_processor_alias')) {
         // Prevent the alias-based path processor, which requires a url_alias db
         // table, from being registered to the path processor manager. We do this
         // by removing the tags that the compiler pass looks for. This means the
         // url generator can safely be used within tests.
         $container->getDefinition('path_processor_alias')->clearTag('path_processor_inbound')->clearTag('path_processor_outbound');
     }
     if ($container->hasDefinition('password')) {
         $container->getDefinition('password')->setArguments(array(1));
     }
     TestServiceProvider::addRouteProvider($container);
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:37,代码来源:KernelTestBase.php

示例4: register

  /**
   * Registers test-specific services.
   *
   * Extend this method in your test to register additional services. This
   * method is called whenever the kernel is rebuilt.
   *
   * @param \Drupal\Core\DependencyInjection\ContainerBuilder $container
   *   The service container to enhance.
   *
   * @see \Drupal\Tests\KernelTestBase::bootKernel()
   */
  public function register(ContainerBuilder $container) {
    // Keep the container object around for tests.
    $this->container = $container;

    $container
      ->register('flood', 'Drupal\Core\Flood\MemoryBackend')
      ->addArgument(new Reference('request_stack'));
    $container
      ->register('lock', 'Drupal\Core\Lock\NullLockBackend');
    $container
      ->register('cache_factory', 'Drupal\Core\Cache\MemoryBackendFactory');
    $container
      ->register('keyvalue.memory', 'Drupal\Core\KeyValueStore\KeyValueMemoryFactory')
      // Must persist container rebuilds, or all data would vanish otherwise.
      ->addTag('persist');
    $container
      ->setAlias('keyvalue', 'keyvalue.memory');

    if ($this->strictConfigSchema) {
      $container
        ->register('simpletest.config_schema_checker', 'Drupal\Core\Config\Testing\ConfigSchemaChecker')
        ->addArgument(new Reference('config.typed'))
        ->addTag('event_subscriber');
    }

    if ($container->hasDefinition('path_processor_alias')) {
      // Prevent the alias-based path processor, which requires a url_alias db
      // table, from being registered to the path processor manager. We do this
      // by removing the tags that the compiler pass looks for. This means the
      // url generator can safely be used within tests.
      $container->getDefinition('path_processor_alias')
        ->clearTag('path_processor_inbound')
        ->clearTag('path_processor_outbound');
    }

    if ($container->hasDefinition('password')) {
      $container->getDefinition('password')
        ->setArguments(array(1));
    }
  }
开发者ID:komejo,项目名称:article-test,代码行数:51,代码来源:KernelTestBase.php


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