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


PHP FormatterBase::view方法代碼示例

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


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

示例1: view

 /**
  * {@inheritdoc}
  *
  * @see ::prepareView()
  * @see ::getEntitiestoView()
  */
 public function view(FieldItemListInterface $items, $langcode = NULL)
 {
     $elements = parent::view($items, $langcode);
     $field_level_access_cacheability = new CacheableMetadata();
     // Try to map the cacheability of the access result that was set at
     // _accessCacheability in getEntitiesToView() to the corresponding render
     // subtree. If no such subtree is found, then merge it with the field-level
     // access cacheability.
     foreach ($items as $delta => $item) {
         // Ignore items for which access cacheability could not be determined in
         // prepareView().
         if (!empty($item->_accessCacheability)) {
             if (isset($elements[$delta])) {
                 CacheableMetadata::createFromRenderArray($elements[$delta])->merge($item->_accessCacheability)->applyTo($elements[$delta]);
             } else {
                 $field_level_access_cacheability = $field_level_access_cacheability->merge($item->_accessCacheability);
             }
         }
     }
     // Apply the cacheability metadata for the inaccessible entities and the
     // entities for which the corresponding render subtree could not be found.
     // This causes the field to be rendered (and cached) according to the cache
     // contexts by which the access results vary, to ensure only users with
     // access to this field can view it. It also tags this field with the cache
     // tags on which the access results depend, to ensure users that cannot view
     // this field at the moment will gain access once any of those cache tags
     // are invalidated.
     $field_level_access_cacheability->applyTo($elements);
     return $elements;
 }
開發者ID:aWEBoLabs,項目名稱:taxi,代碼行數:36,代碼來源:EntityReferenceFormatterBase.php

示例2: view

 /**
  * This method is the wrapper for the formatter.
  */
 public function view(FieldItemListInterface $items, $langcode = NULL)
 {
     $elements = parent::view($items);
     $types = $this->getRemoteTypes();
     $elements['#prefix'] = '<p>The cover source is: ' . $types[$this->settings['cover_source']] . '</p>';
     return $elements;
 }
開發者ID:Happyculture,項目名稱:exercices,代碼行數:10,代碼來源:RemoteCover.php


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