You are here

class QuizEventSubscriber in Quiz 8.5

Same name and namespace in other branches
  1. 8.6 src/EventSubscriber/QuizEventSubscriber.php \Drupal\quiz\EventSubscriber\QuizEventSubscriber
  2. 6.x src/EventSubscriber/QuizEventSubscriber.php \Drupal\quiz\EventSubscriber\QuizEventSubscriber

Hierarchy

  • class \Drupal\quiz\EventSubscriber\QuizEventSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of QuizEventSubscriber

1 string reference to 'QuizEventSubscriber'
quiz.services.yml in ./quiz.services.yml
quiz.services.yml
1 service uses QuizEventSubscriber
quiz_event_subscriber in ./quiz.services.yml
\Drupal\quiz\EventSubscriber\QuizEventSubscriber

File

src/EventSubscriber/QuizEventSubscriber.php, line 11

Namespace

Drupal\quiz\EventSubscriber
View source
class QuizEventSubscriber implements EventSubscriberInterface {
  public static function getSubscribedEvents() {
    return [
      'replicate__after_save' => [
        'afterSave',
      ],
    ];
  }

  /**
   * If the current node is a course object, fulfill it for the current user.
   *
   * @param ReplicateEntityEvent $event
   */
  public function afterSave(AfterSaveEvent $event) {

    /* @var $quiz Quiz */
    $quiz = $event
      ->getEntity();
    $old_quiz = Drupal::entityTypeManager()
      ->getStorage('quiz')
      ->loadRevision($quiz->old_vid);
    $quiz
      ->copyFromRevision($old_quiz);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
QuizEventSubscriber::afterSave public function If the current node is a course object, fulfill it for the current user.
QuizEventSubscriber::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.