You are here

function multiple_registration_entity_operation_alter in Multiple Registration 8

Same name and namespace in other branches
  1. 8.2 multiple_registration.module \multiple_registration_entity_operation_alter()
  2. 3.x multiple_registration.module \multiple_registration_entity_operation_alter()

Implements hook_entity_operation_alter().

File

./multiple_registration.module, line 62
Contains multiple_registration.module.

Code

function multiple_registration_entity_operation_alter(array &$operations, EntityInterface $entity) {
  if ($entity
    ->getEntityTypeId() === 'user_role') {
    if (\Drupal::service('router.route_provider')
      ->getRouteByName("multiple_registration.create_registration_page_form")) {
      $available_roles = \Drupal::service('multiple_registration.service')
        ->getAvailableRoles();
      if (!in_array($entity
        ->id(), array_keys($available_roles))) {
        return;
      }
      $operations['add_registration_page'] = [
        'title' => t('Add own registration page'),
        'url' => Url::fromRoute("multiple_registration.create_registration_page_form", [
          'rid' => $entity
            ->id(),
        ]),
        'weight' => 50,
      ];
    }
  }
}