當前位置: 首頁>>代碼示例>>PHP>>正文


PHP EntityTypeInterface::isStaticallyCacheable方法代碼示例

本文整理匯總了PHP中Drupal\Core\Entity\EntityTypeInterface::isStaticallyCacheable方法的典型用法代碼示例。如果您正苦於以下問題:PHP EntityTypeInterface::isStaticallyCacheable方法的具體用法?PHP EntityTypeInterface::isStaticallyCacheable怎麽用?PHP EntityTypeInterface::isStaticallyCacheable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Drupal\Core\Entity\EntityTypeInterface的用法示例。


在下文中一共展示了EntityTypeInterface::isStaticallyCacheable方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: loadMultiple

 /**
  * {@inheritdoc}
  */
 public function loadMultiple(array $ids = NULL)
 {
     $entities = array();
     // Create a new variable which is either a prepared version of the $ids
     // array for later comparison with the entity cache, or FALSE if no $ids
     // were passed. The $ids array is reduced as items are loaded from cache,
     // and we need to know if it's empty for this reason to avoid querying the
     // database when all requested entities are loaded from cache.
     $passed_ids = !empty($ids) ? array_flip($ids) : FALSE;
     // Try to load entities from the static cache, if the entity type supports
     // static caching.
     if ($this->entityType->isStaticallyCacheable() && $ids) {
         $entities += $this->getFromStaticCache($ids);
         // If any entities were loaded, remove them from the ids still to load.
         if ($passed_ids) {
             $ids = array_keys(array_diff_key($passed_ids, $entities));
         }
     }
     // Load any remaining entities from the database. This is the case if $ids
     // is set to NULL (so we load all entities) or if there are any ids left to
     // load.
     if ($ids === NULL || $ids) {
         $queried_entities = $this->doLoadMultiple($ids);
     }
     // Pass all entities loaded from the database through $this->postLoad(),
     // which attaches fields (if supported by the entity type) and calls the
     // entity type specific load callback, for example hook_node_load().
     if (!empty($queried_entities)) {
         $this->postLoad($queried_entities);
         $entities += $queried_entities;
     }
     if ($this->entityType->isStaticallyCacheable()) {
         // Add entities to the cache.
         if (!empty($queried_entities)) {
             $this->setStaticCache($queried_entities);
         }
     }
     // Ensure that the returned array is ordered the same as the original
     // $ids array if this was passed in and remove any invalid ids.
     if ($passed_ids) {
         // Remove any invalid ids from the array.
         $passed_ids = array_intersect_key($passed_ids, $entities);
         foreach ($entities as $entity) {
             $passed_ids[$entity->id()] = $entity;
         }
         $entities = $passed_ids;
     }
     return $entities;
 }
開發者ID:nstielau,項目名稱:drops-8,代碼行數:52,代碼來源:EntityStorageBase.php


注:本文中的Drupal\Core\Entity\EntityTypeInterface::isStaticallyCacheable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。