You are here

public function ModuleBuilderComponentListBuilder::getDefaultOperations in Module Builder 8.3

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

src/ModuleBuilderComponentListBuilder.php, line 52

Class

ModuleBuilderComponentListBuilder
Defines a class to build a listing of module builder components.

Namespace

Drupal\module_builder

Code

public function getDefaultOperations(EntityInterface $entity) {
  $operations = parent::getDefaultOperations($entity);
  $component_sections_handler = \Drupal::service('entity_type.manager')
    ->getHandler($this->entityTypeId, 'component_sections');
  $form_operations = $component_sections_handler
    ->getOperations();
  if (isset($operations['edit'])) {
    $operations['edit']['title'] = t('Edit info');
    $operations['edit']['weight'] = 0;
  }
  $weight = 1;
  foreach ($form_operations as $operation_name => $title) {
    $operations[$operation_name] = array(
      'title' => t($title),
      'url' => $entity
        ->toUrl("{$operation_name}-form"),
      'weight' => $weight,
    );
    $weight++;
  }
  return $operations;
}