You are here

public function CourseEnrollmentCreateAction::execute in Course 8.3

Same name and namespace in other branches
  1. 8.2 src/Plugin/Action/CourseEnrollmentCreateAction.php \Drupal\course\Plugin\Action\CourseEnrollmentCreateAction::execute()
  2. 3.x src/Plugin/Action/CourseEnrollmentCreateAction.php \Drupal\course\Plugin\Action\CourseEnrollmentCreateAction::execute()

File

src/Plugin/Action/CourseEnrollmentCreateAction.php, line 27

Class

CourseEnrollmentCreateAction
Action description.

Namespace

Drupal\course\Plugin\Action

Code

public function execute($entity = NULL) {

  /* @var $url Drupal\Core\Url */
  $url = $this->context['redirect_url'];
  $cid = $url
    ->getRouteParameters()['course'];
  $course = Course::load($cid);
  $course
    ->enroll($entity);
  return $this
    ->t('Enrolled user.');
}