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


PHP EntityManagerInterface::getViewModeOptions方法代碼示例

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


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

示例1: blockForm

 /**
  * Overrides \Drupal\Core\Block\BlockBase::blockForm().
  *
  * Adds body and description fields to the block configuration form.
  */
 public function blockForm($form, FormStateInterface $form_state)
 {
     $options = $this->entityManager->getViewModeOptions('block_content');
     $form['view_mode'] = array('#type' => 'select', '#options' => $options, '#title' => $this->t('View mode'), '#description' => $this->t('Output the block in this view mode.'), '#default_value' => $this->configuration['view_mode'], '#access' => count($options) > 1);
     $form['title']['#description'] = $this->t('The title of the block as shown to the user.');
     return $form;
 }
開發者ID:nstielau,項目名稱:drops-8,代碼行數:12,代碼來源:BlockContentBlock.php

示例2: buildOptionsForm

 /**
  * {@inheritdoc}
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     $form['view_mode'] = array('#type' => 'select', '#options' => $this->entityManager->getViewModeOptions($this->entityType), '#title' => $this->t('View mode'), '#default_value' => $this->options['view_mode']);
     $label = $this->entityManager->getDefinition($this->entityType)->getLabel();
     $target = $this->options['target'];
     // If the target does not contain tokens, try to load the entity and
     // display the entity ID to the admin form user.
     // @todo Use a method to check for tokens in
     //   https://www.drupal.org/node/2396607.
     if (strpos($this->options['target'], '{{') === FALSE) {
         // @todo If the entity does not exist, this will will show the config
         //   target identifier. Decide if this is the correct behavior in
         //   https://www.drupal.org/node/2415391.
         if ($target_entity = $this->entityManager->loadEntityByConfigTarget($this->entityType, $this->options['target'])) {
             $target = $target_entity->id();
         }
     }
     $form['target'] = ['#title' => $this->t('@entity_type_label ID', ['@entity_type_label' => $label]), '#type' => 'textfield', '#default_value' => $target];
     $form['bypass_access'] = array('#type' => 'checkbox', '#title' => $this->t('Bypass access checks'), '#description' => $this->t('If enabled, access permissions for rendering the entity are not checked.'), '#default_value' => !empty($this->options['bypass_access']));
 }
開發者ID:sgtsaughter,項目名稱:d8portfolio,代碼行數:24,代碼來源:Entity.php

示例3: blockForm

 /**
  * {@inheritdoc}
  */
 public function blockForm($form, FormStateInterface $form_state)
 {
     $form['view_mode'] = ['#type' => 'select', '#options' => $this->entityManager->getViewModeOptions($this->getDerivativeId()), '#title' => $this->t('View mode'), '#default_value' => $this->configuration['view_mode']];
     return $form;
 }
開發者ID:AllieRays,項目名稱:debugging-drupal-8,代碼行數:8,代碼來源:EntityView.php

示例4: buildOptionsForm

 /**
  * {@inheritdoc}
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     $form['view_mode'] = ['#type' => 'select', '#options' => $this->entityManager->getViewModeOptions($this->getEntityTypeId()), '#title' => $this->t('View mode'), '#default_value' => $this->options['view_mode']];
 }
開發者ID:darrylri,項目名稱:protovbmwmo,代碼行數:8,代碼來源:RenderedEntity.php

示例5: getViewModeOptions

 /**
  * {@inheritdoc}
  */
 public function getViewModeOptions($entity_type_id, $include_disabled = FALSE)
 {
     return $this->entityManager->getViewModeOptions($entity_type_id, $include_disabled);
 }
開發者ID:ddrozdik,項目名稱:dmaps,代碼行數:7,代碼來源:EntityManagerWrapper.php


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