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


PHP EntityInterface::isFallbackFormat方法代碼示例

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


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

示例1: checkAccess

 /**
  * {@inheritdoc}
  */
 protected function checkAccess(EntityInterface $filter_format, $operation, $langcode, AccountInterface $account)
 {
     /** @var \Drupal\filter\FilterFormatInterface $filter_format */
     // All users are allowed to use the fallback filter.
     if ($operation == 'use') {
         if ($filter_format->isFallbackFormat()) {
             return AccessResult::allowed();
         } else {
             return AccessResult::allowedIfHasPermission($account, $filter_format->getPermissionName());
         }
     }
     // The fallback format may not be disabled.
     if ($operation == 'disable' && $filter_format->isFallbackFormat()) {
         return AccessResult::forbidden();
     }
     // We do not allow filter formats to be deleted through the UI, because that
     // would render any content that uses them unusable.
     if ($operation == 'delete') {
         return AccessResult::forbidden();
     }
     if (in_array($operation, array('disable', 'update'))) {
         return parent::checkAccess($filter_format, $operation, $langcode, $account);
     }
     // No opinion.
     return AccessResult::neutral();
 }
開發者ID:davidsoloman,項目名稱:drupalconsole.com,代碼行數:29,代碼來源:FilterFormatAccessControlHandler.php

示例2: buildRow

 /**
  * {@inheritdoc}
  */
 public function buildRow(EntityInterface $entity)
 {
     // Check whether this is the fallback text format. This format is available
     // to all roles and cannot be disabled via the admin interface.
     $row['label'] = $entity->label();
     $row['roles'] = [];
     if ($entity->isFallbackFormat()) {
         $fallback_choice = $this->configFactory->get('filter.settings')->get('always_show_fallback_choice');
         if ($fallback_choice) {
             $row['roles']['#markup'] = $this->t('All roles may use this format');
         } else {
             $row['roles']['#markup'] = $this->t('This format is shown when no other formats are available');
         }
         // Emphasize the fallback role text since it is important to understand
         // how it works which configuring filter formats. Additionally, it is not
         // a list of roles unlike the other values in this column.
         $row['roles']['#prefix'] = '<em>';
         $row['roles']['#suffix'] = '</em>';
     } else {
         $row['roles'] = ['#theme' => 'item_list', '#items' => filter_get_roles_by_format($entity), '#empty' => $this->t('No roles may use this format'), '#context' => ['list_style' => 'comma-list']];
     }
     return $row + parent::buildRow($entity);
 }
開發者ID:aWEBoLabs,項目名稱:taxi,代碼行數:26,代碼來源:FilterFormatListBuilder.php

示例3: buildRow

 /**
  * {@inheritdoc}
  */
 public function buildRow(EntityInterface $entity)
 {
     // Check whether this is the fallback text format. This format is available
     // to all roles and cannot be disabled via the admin interface.
     if ($entity->isFallbackFormat()) {
         $row['label'] = SafeMarkup::placeholder($entity->label());
         $fallback_choice = $this->configFactory->get('filter.settings')->get('always_show_fallback_choice');
         if ($fallback_choice) {
             $roles_markup = SafeMarkup::placeholder($this->t('All roles may use this format'));
         } else {
             $roles_markup = SafeMarkup::placeholder($this->t('This format is shown when no other formats are available'));
         }
     } else {
         $row['label'] = $this->getLabel($entity);
         $roles = array_map('\\Drupal\\Component\\Utility\\SafeMarkup::checkPlain', filter_get_roles_by_format($entity));
         $roles_markup = $roles ? implode(', ', $roles) : $this->t('No roles may use this format');
     }
     $row['roles'] = !empty($this->weightKey) ? array('#markup' => $roles_markup) : $roles_markup;
     return $row + parent::buildRow($entity);
 }
開發者ID:nstielau,項目名稱:drops-8,代碼行數:23,代碼來源:FilterFormatListBuilder.php


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