public function Entity::buildOptionsForm in Zircon Profile 8.0
Same name in this branch
- 8.0 core/modules/views/src/Plugin/views/area/Entity.php \Drupal\views\Plugin\views\area\Entity::buildOptionsForm()
- 8.0 core/modules/views/src/Plugin/views/argument_validator/Entity.php \Drupal\views\Plugin\views\argument_validator\Entity::buildOptionsForm()
Same name and namespace in other branches
- 8 core/modules/views/src/Plugin/views/area/Entity.php \Drupal\views\Plugin\views\area\Entity::buildOptionsForm()
Provide a form to edit options for this plugin.
Overrides TokenizeAreaPluginBase::buildOptionsForm
File
- core/
modules/ views/ src/ Plugin/ views/ area/ Entity.php, line 98 - Contains \Drupal\views\Plugin\views\area\Entity.
Class
- Entity
- Provides an area handler which renders an entity in a certain view mode.
Namespace
Drupal\views\Plugin\views\areaCode
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']),
);
}