FieldConfigListBuilder::getDefaultOperations

public FieldConfigListBuilder::getDefaultOperations(EntityInterface $entity)

Gets this list's default operations.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity the operations are for.

Return value

array The array structure is identical to the return value of self::getOperations().

Overrides ConfigEntityListBuilder::getDefaultOperations

File

core/modules/field_ui/src/FieldConfigListBuilder.php, line 155

Class

FieldConfigListBuilder
Provides lists of field config entities.

Namespace

Drupal\field_ui

Code

public function getDefaultOperations(EntityInterface $entity) {
  /** @var \Drupal\field\FieldConfigInterface $entity */
  $operations = parent::getDefaultOperations($entity);

  if ($entity->access('update') && $entity->hasLinkTemplate("{$entity->getTargetEntityTypeId()}-field-edit-form")) {
    $operations['edit'] = array(
      'title' => $this->t('Edit'),
      'weight' => 10,
      'url' => $entity->urlInfo("{$entity->getTargetEntityTypeId()}-field-edit-form"),
    );
  }
  if ($entity->access('delete') && $entity->hasLinkTemplate("{$entity->getTargetEntityTypeId()}-field-delete-form")) {
    $operations['delete'] = array(
      'title' => $this->t('Delete'),
      'weight' => 100,
      'url' => $entity->urlInfo("{$entity->getTargetEntityTypeId()}-field-delete-form"),
    );
  }

  $operations['storage-settings'] = array(
    'title' => $this->t('Storage settings'),
    'weight' => 20,
    'attributes' => array('title' => $this->t('Edit storage settings.')),
    'url' => $entity->urlInfo("{$entity->getTargetEntityTypeId()}-storage-edit-form"),
  );
  $operations['edit']['attributes']['title'] = $this->t('Edit field settings.');
  $operations['delete']['attributes']['title'] = $this->t('Delete field.');

  return $operations;
}
doc_Drupal
2016-10-29 09:11:14
Comments
Leave a Comment

Please login to continue.