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


PHP Drupal::hasContainer方法代码示例

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


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

示例1: __wakeup

 /**
  * {@inheritdoc}
  */
 public function __wakeup()
 {
     // Tests in isolation potentially unserialize in the parent process.
     if (isset($GLOBALS['__PHPUNIT_BOOTSTRAP']) && !\Drupal::hasContainer()) {
         return;
     }
     $container = \Drupal::getContainer();
     foreach ($this->_serviceIds as $key => $service_id) {
         $this->{$key} = $container->get($service_id);
     }
     $this->_serviceIds = array();
 }
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:15,代码来源:DependencySerializationTrait.php

示例2: testDrupalGetFilename

 /**
  * Tests that drupal_get_filename() works when the file is not in database.
  */
 function testDrupalGetFilename()
 {
     // drupal_get_profile() is using obtaining the profile from state if the
     // install_state global is not set.
     global $install_state;
     $install_state['parameters']['profile'] = 'testing';
     // Assert that this test is meaningful.
     $this->assertNull($this->container);
     $this->assertFalse(\Drupal::hasContainer());
     // Retrieving the location of a module.
     $this->assertIdentical(drupal_get_filename('module', 'system'), 'core/modules/system/system.info.yml');
     // Retrieving the location of a theme.
     $this->assertIdentical(drupal_get_filename('theme', 'stark'), 'core/themes/stark/stark.info.yml');
     // Retrieving the location of a theme engine.
     $this->assertIdentical(drupal_get_filename('theme_engine', 'phptemplate'), 'core/themes/engines/phptemplate/phptemplate.info.yml');
     // Retrieving the location of a profile. Profiles are a special case with
     // a fixed location and naming.
     $this->assertIdentical(drupal_get_filename('profile', 'standard'), 'core/profiles/standard/standard.info.yml');
     // Searching for an item that does not exist returns NULL.
     $this->assertNull(drupal_get_filename('module', uniqid("", TRUE)), 'Searching for an item that does not exist returns NULL.');
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:24,代码来源:GetFilenameUnitTest.php

示例3: unserialize

 /**
  * {@inheritdoc}
  */
 public function unserialize($serialized)
 {
     list($storage, $current_display, $args, $current_page, $exposed_input, $exposed_raw_input, $exposed_data, $dom_id, $executed) = unserialize($serialized);
     // There are cases, like in testing, where we don't have a container
     // available.
     if (\Drupal::hasContainer()) {
         $this->setRequest(\Drupal::request());
         $this->user = \Drupal::currentUser();
         $this->storage = \Drupal::entityManager()->getStorage('view')->load($storage);
         $this->setDisplay($current_display);
         $this->setArguments($args);
         $this->setCurrentPage($current_page);
         $this->setExposedInput($exposed_input);
         $this->exposed_data = $exposed_data;
         $this->exposed_raw_input = $exposed_raw_input;
         $this->dom_id = $dom_id;
         $this->initHandlers();
         // If the display was previously executed, execute it now.
         if ($executed) {
             $this->execute($this->current_display);
         }
     }
 }
开发者ID:DrupalCamp-NYC,项目名称:dcnyc16,代码行数:26,代码来源:ViewExecutable.php

示例4: setupEntityTypeManager

 /**
  * Sets up the entity type manager in the container.
  *
  * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
  *   The entity type manager.
  */
 protected function setupEntityTypeManager(EntityTypeManagerInterface $entity_type_manager)
 {
     $container = \Drupal::hasContainer() ? \Drupal::getContainer() : new ContainerBuilder();
     $container->set('entity_type.manager', $entity_type_manager);
     $container->set('entity.manager', $entity_type_manager);
     \Drupal::setContainer($container);
 }
开发者ID:DrupalCamp-NYC,项目名称:dcnyc16,代码行数:13,代码来源:SqlTest.php

示例5: setupNullCacheabilityMetadataValidation

  protected function setupNullCacheabilityMetadataValidation() {
    $container = \Drupal::hasContainer() ? \Drupal::getContainer() : new ContainerBuilder();

    $cache_context_manager = $this->prophesize(CacheContextsManager::class);

    $container->set('cache_contexts_manager', $cache_context_manager->reveal());
    \Drupal::setContainer($container);
  }
开发者ID:komejo,项目名称:article-test,代码行数:8,代码来源:LocalTaskManagerTest.php

示例6: setupNullCacheabilityMetadataValidation

 protected function setupNullCacheabilityMetadataValidation()
 {
     $container = \Drupal::hasContainer() ? \Drupal::getContainer() : new ContainerBuilder();
     $cache_context_manager = $this->prophesize(CacheContextsManager::class);
     foreach ([NULL, ['user.permissions'], ['route'], ['route', 'context.example1'], ['context.example1', 'route'], ['context.example1', 'route', 'context.example2'], ['context.example1', 'context.example2', 'route'], ['context.example1', 'context.example2', 'route', 'user.permissions']] as $argument) {
         $cache_context_manager->assertValidTokens($argument)->willReturn(TRUE);
     }
     $container->set('cache_contexts_manager', $cache_context_manager->reveal());
     \Drupal::setContainer($container);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:10,代码来源:LocalTaskManagerTest.php


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