You are here

protected function GroupTypeController::getDefaultOperations in Group 8

Same name and namespace in other branches
  1. 2.0.x src/Entity/Controller/GroupTypeController.php \Drupal\group\Entity\Controller\GroupTypeController::getDefaultOperations()

Gets the group type's content plugin's default operation links.

Parameters

\Drupal\group\Plugin\GroupContentEnablerInterface $plugin: The content enabler plugin to build operation links for.

bool $is_installed: Whether the plugin is installed.

Return value

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

1 call to GroupTypeController::getDefaultOperations()
GroupTypeController::getOperations in src/Entity/Controller/GroupTypeController.php
Provides an array of information to build a list of operation links.

File

src/Entity/Controller/GroupTypeController.php, line 223

Class

GroupTypeController
Provides the user permissions administration form for a specific group type.

Namespace

Drupal\group\Entity\Controller

Code

protected function getDefaultOperations($plugin, $is_installed) {
  $operations = [];
  $plugin_id = $plugin
    ->getPluginId();
  $ui_allowed = !$plugin
    ->isEnforced() && !$plugin
    ->isCodeOnly();
  if ($is_installed) {

    /** @var \Drupal\group\Entity\GroupContentTypeInterface $group_content_type */
    $group_content_type_id = $plugin
      ->getContentTypeConfigId();
    $group_content_type = GroupContentType::load($group_content_type_id);
    $route_params = [
      'group_content_type' => $group_content_type_id,
    ];
    $operations['configure'] = [
      'title' => $this
        ->t('Configure'),
      'url' => new Url('entity.group_content_type.edit_form', $route_params),
    ];
    if ($ui_allowed) {
      $operations['uninstall'] = [
        'title' => $this
          ->t('Uninstall'),
        'weight' => 99,
        'url' => new Url('entity.group_content_type.delete_form', $route_params),
      ];
    }
    if ($this->moduleHandler
      ->moduleExists('field_ui')) {
      $operations += field_ui_entity_operation($group_content_type);
    }
  }
  elseif ($ui_allowed) {
    $operations['install'] = [
      'title' => $this
        ->t('Install'),
      'url' => new Url('entity.group_content_type.add_form', [
        'group_type' => $this->groupType
          ->id(),
        'plugin_id' => $plugin_id,
      ]),
    ];
  }
  return $operations;
}