You are here

class EventEnrollmentEntityDeleteAction in Open Social 8.7

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_event/modules/social_event_managers/src/Plugin/Action/EventEnrollmentEntityDeleteAction.php \Drupal\social_event_managers\Plugin\Action\EventEnrollmentEntityDeleteAction
  2. 8.5 modules/social_features/social_event/modules/social_event_managers/src/Plugin/Action/EventEnrollmentEntityDeleteAction.php \Drupal\social_event_managers\Plugin\Action\EventEnrollmentEntityDeleteAction
  3. 8.6 modules/social_features/social_event/modules/social_event_managers/src/Plugin/Action/EventEnrollmentEntityDeleteAction.php \Drupal\social_event_managers\Plugin\Action\EventEnrollmentEntityDeleteAction
  4. 8.8 modules/social_features/social_event/modules/social_event_managers/src/Plugin/Action/EventEnrollmentEntityDeleteAction.php \Drupal\social_event_managers\Plugin\Action\EventEnrollmentEntityDeleteAction
  5. 10.3.x modules/social_features/social_event/modules/social_event_managers/src/Plugin/Action/EventEnrollmentEntityDeleteAction.php \Drupal\social_event_managers\Plugin\Action\EventEnrollmentEntityDeleteAction
  6. 10.0.x modules/social_features/social_event/modules/social_event_managers/src/Plugin/Action/EventEnrollmentEntityDeleteAction.php \Drupal\social_event_managers\Plugin\Action\EventEnrollmentEntityDeleteAction
  7. 10.1.x modules/social_features/social_event/modules/social_event_managers/src/Plugin/Action/EventEnrollmentEntityDeleteAction.php \Drupal\social_event_managers\Plugin\Action\EventEnrollmentEntityDeleteAction
  8. 10.2.x modules/social_features/social_event/modules/social_event_managers/src/Plugin/Action/EventEnrollmentEntityDeleteAction.php \Drupal\social_event_managers\Plugin\Action\EventEnrollmentEntityDeleteAction

Delete event enrollment entity action.

Plugin annotation


@Action(
  id = "social_event_managers_delete_event_enrollment_action",
  label = @Translation("Delete selected event enrollment entities"),
  type = "event_enrollment",
  confirm = TRUE,
  confirm_form_route_name = "social_event_managers.vbo.confirm",
)

Hierarchy

Expanded class hierarchy of EventEnrollmentEntityDeleteAction

File

modules/social_features/social_event/modules/social_event_managers/src/Plugin/Action/EventEnrollmentEntityDeleteAction.php, line 22

Namespace

Drupal\social_event_managers\Plugin\Action
View source
class EventEnrollmentEntityDeleteAction extends ViewsBulkOperationsActionBase {

  /**
   * {@inheritdoc}
   */
  public function execute($entity = NULL) {

    /** @var \Drupal\social_event\EventEnrollmentInterface $entity */
    $entity
      ->delete();
  }

  /**
   * {@inheritdoc}
   */
  public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
    $access = AccessResult::forbidden();
    if ($object instanceof EventEnrollmentInterface) {
      $access = $object
        ->access('delete', $account, TRUE);
      $event_id = $object
        ->getFieldValue('field_event', 'target_id');
      $node = \Drupal::entityTypeManager()
        ->getStorage('node')
        ->load($event_id);

      // Also Event organizers can do this.
      if ($node instanceof NodeInterface && social_event_manager_or_organizer($node)) {
        $access = AccessResult::allowedIf($object instanceof EventEnrollmentInterface);
      }
    }
    return $return_as_object ? $access : $access
      ->isAllowed();
  }

}

Members