當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。