本文整理汇总了PHP中Drupal\Core\Entity\EntityTypeInterface::isRenderCacheable方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityTypeInterface::isRenderCacheable方法的具体用法?PHP EntityTypeInterface::isRenderCacheable怎么用?PHP EntityTypeInterface::isRenderCacheable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Entity\EntityTypeInterface
的用法示例。
在下文中一共展示了EntityTypeInterface::isRenderCacheable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getBuildDefaults
/**
* Provides entity-specific defaults to the build process.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity for which the defaults should be provided.
* @param string $view_mode
* The view mode that should be used.
* @param string $langcode
* For which language the entity should be prepared, defaults to
* the current content language.
*
* @return array
*/
protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langcode)
{
// Allow modules to change the view mode.
$context = array('langcode' => $langcode);
$this->moduleHandler()->alter('entity_view_mode', $view_mode, $entity, $context);
$build = array('#theme' => $this->entityTypeId, "#{$this->entityTypeId}" => $entity, '#view_mode' => $view_mode, '#langcode' => $langcode, '#cache' => array('tags' => Cache::mergeTags($this->getCacheTags(), $entity->getCacheTags()), 'contexts' => $entity->getCacheContexts(), 'max-age' => $entity->getCacheMaxAge()));
// Cache the rendered output if permitted by the view mode and global entity
// type configuration.
if ($this->isViewModeCacheable($view_mode) && !$entity->isNew() && $entity->isDefaultRevision() && $this->entityType->isRenderCacheable()) {
$build['#cache'] += array('keys' => array('entity_view', $this->entityTypeId, $entity->id(), $view_mode), 'bin' => $this->cacheBin);
if ($entity instanceof TranslatableInterface && count($entity->getTranslationLanguages()) > 1) {
$build['#cache']['keys'][] = $langcode;
}
}
return $build;
}