You are here

public function Subgroup::getGroupOperations in Subgroup (Graph) 1.0.x

File

src/Plugin/GroupContentEnabler/Subgroup.php, line 41

Class

Subgroup
Provides a content enabler for subgroups.

Namespace

Drupal\ggroup\Plugin\GroupContentEnabler

Code

public function getGroupOperations(GroupInterface $group) {
  $account = \Drupal::currentUser();
  $plugin_id = $this
    ->getPluginId();
  $type = $this
    ->getEntityBundle();
  $operations = [];
  if ($group
    ->hasPermission("create {$plugin_id} entity", $account)) {
    $route_params = [
      'group' => $group
        ->id(),
      'group_type' => $this
        ->getEntityBundle(),
    ];
    $operations["ggroup_create-{$type}"] = [
      'title' => $this
        ->t('Create @type', [
        '@type' => $this
          ->getSubgroupType()
          ->label(),
      ]),
      'url' => new Url('entity.group_content.subgroup_add_form', $route_params),
      'weight' => 35,
    ];
  }
  return $operations;
}