本文整理汇总了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;
}
示例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']));
}
示例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;
}
示例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']];
}
示例5: getViewModeOptions
/**
* {@inheritdoc}
*/
public function getViewModeOptions($entity_type_id, $include_disabled = FALSE)
{
return $this->entityManager->getViewModeOptions($entity_type_id, $include_disabled);
}