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


PHP ContainerBuilder::getParameter方法代码示例

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


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

示例1: register

 /**
  * Registers services to the container.
  *
  * @param ContainerBuilder $container
  *   The ContainerBuilder to register services to.
  */
 public function register(ContainerBuilder $container)
 {
     static::$container = $container;
     $class_map = $this->AutoloaderInit();
     $ns = [];
     foreach ($class_map as $name => $path) {
         $path = preg_replace("/\\.php\$/i", '', $path);
         $path = explode(DIRECTORY_SEPARATOR, $path);
         $name = explode('\\', $name);
         while (end($path) === end($name)) {
             array_pop($path);
             array_pop($name);
         }
         $path = implode(DIRECTORY_SEPARATOR, $path);
         $name = implode('\\', $name);
         if (is_dir($path)) {
             if (is_dir($path . '/Plugin') || is_dir($path . '/Entity') || is_dir($path . '/Element')) {
                 $ns[$name][] = $path;
             }
         }
     }
     foreach ($ns as $name => $path) {
         $path = array_unique($path);
         $ns[$name] = count($path) == 1 ? reset($path) : $path;
     }
     $ns += $container->getParameter('container.namespaces');
     $container->setParameter('container.namespaces', $ns);
     $yaml_loader = new YamlFileLoader($container);
     foreach (static::getFiles('/^.+\\.services\\.yml$/i') as $file) {
         $yaml_loader->load($file);
     }
 }
开发者ID:d-f-d,项目名称:d_submodules,代码行数:38,代码来源:DSubmodulesServiceProvider.php

示例2: alter

 /**
  * {@inheritdoc}
  */
 public function alter(ContainerBuilder $container)
 {
     $modules = $container->getParameter('container.modules');
     // Check for installed Replicate module.
     if (isset($modules['replicate'])) {
         // Add a Replicate field event subscriber.
         $service_definition = new Definition('Drupal\\paragraphs\\EventSubscriber\\ReplicateFieldSubscriber', [new Reference('replicate.replicator')]);
         $service_definition->addTag('event_subscriber');
         $container->setDefinition('replicate.event_subscriber.paragraphs', $service_definition);
     }
 }
开发者ID:eric-shell,项目名称:eric-shell-d8,代码行数:14,代码来源:ParagraphsServiceProvider.php

示例3: alter

 /**
  * {@inheritdoc}
  */
 public function alter(ContainerBuilder $container)
 {
     $modules = $container->getParameter('container.modules');
     if (isset($modules['hal'])) {
         // Hal module is enabled, add our new normalizer for entity reference
         // revision items.
         $service_definition = new Definition('Drupal\\entity_reference_revisions\\Normalizer\\EntityReferenceRevisionItemNormalizer', array(new Reference('rest.link_manager'), new Reference('serializer.entity_resolver')));
         // The priority must be higher than that of
         // serializer.normalizer.entity_reference_item.hal in
         // hal.services.yml.
         $service_definition->addTag('normalizer', array('priority' => 20));
         $container->setDefinition('serializer.normalizer.entity_reference_revision_item', $service_definition);
     }
 }
开发者ID:eric-shell,项目名称:eric-shell-d8,代码行数:17,代码来源:EntityReferenceRevisionsServiceProvider.php

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

示例5: alter

 /**
  * {@inheritdoc}
  */
 public function alter(ContainerBuilder $container)
 {
     $modules = $container->getParameter('container.modules');
     // Alter the views.executable service only if Views module is enabled.
     if (isset($modules['views'])) {
         $container->getDefinition('views.executable')->setClass('Drupal\\webprofiler\\Views\\ViewExecutableFactoryWrapper');
     }
     // Replace the regular form_builder service with a traceable one.
     $container->getDefinition('form_builder')->setClass('Drupal\\webprofiler\\Form\\FormBuilderWrapper');
     // Replace the regular access_manager service with a traceable one.
     $container->getDefinition('access_manager')->setClass('Drupal\\webprofiler\\Access\\AccessManagerWrapper')->addMethodCall('setDataCollector', [new Reference('webprofiler.request')]);
     // Replace the regular theme.negotiator service with a traceable one.
     $container->getDefinition('theme.negotiator')->setClass('Drupal\\webprofiler\\Theme\\ThemeNegotiatorWrapper');
     // Replace the regular config.factory service with a traceable one.
     $container->getDefinition('config.factory')->setClass('Drupal\\webprofiler\\Config\\ConfigFactoryWrapper')->addMethodCall('setDataCollector', [new Reference('webprofiler.config')]);
     // Replace the regular string_translation service with a traceable one.
     $container->getDefinition('string_translation')->setClass('Drupal\\webprofiler\\StringTranslation\\TranslationManagerWrapper');
 }
开发者ID:penguinclub,项目名称:penguinweb_drupal8,代码行数:21,代码来源:WebprofilerServiceProvider.php

示例6: 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);
     // 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:davidsoloman,项目名称:drupalconsole.com,代码行数:23,代码来源:InstallerServiceProvider.php

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

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


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