You are here

class FeedsSubscriber in Feeds 8.3

React on authors being processed.

Hierarchy

  • class \Drupal\feeds_test_events\EventSubscriber\FeedsSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of FeedsSubscriber

1 file declares its use of FeedsSubscriber
FeedsEventsTest.php in tests/src/Kernel/FeedsEventsTest.php
1 string reference to 'FeedsSubscriber'
feeds_test_events.services.yml in tests/modules/feeds_test_events/feeds_test_events.services.yml
tests/modules/feeds_test_events/feeds_test_events.services.yml
1 service uses FeedsSubscriber
feeds_test_events.subscriber in tests/modules/feeds_test_events/feeds_test_events.services.yml
Drupal\feeds_test_events\EventSubscriber\FeedsSubscriber

File

tests/modules/feeds_test_events/src/EventSubscriber/FeedsSubscriber.php, line 22

Namespace

Drupal\feeds_test_events\EventSubscriber
View source
class FeedsSubscriber implements EventSubscriberInterface {

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    return [
      FeedsEvents::FEEDS_DELETE => [
        'onDelete',
      ],
      FeedsEvents::INIT_IMPORT => [
        'onInitImport',
      ],
      FeedsEvents::FETCH => [
        [
          'preFetch',
          FeedsEvents::BEFORE,
        ],
        [
          'postFetch',
          FeedsEvents::AFTER,
        ],
      ],
      FeedsEvents::PARSE => [
        [
          'preParse',
          FeedsEvents::BEFORE,
        ],
        [
          'postParse',
          FeedsEvents::AFTER,
        ],
      ],
      FeedsEvents::PROCESS => [
        [
          'preProcess',
          FeedsEvents::BEFORE,
        ],
        [
          'postProcess',
          FeedsEvents::AFTER,
        ],
      ],
      FeedsEvents::PROCESS_ENTITY_PREVALIDATE => [
        'prevalidate',
      ],
      FeedsEvents::PROCESS_ENTITY_PRESAVE => [
        'preSave',
      ],
      FeedsEvents::PROCESS_ENTITY_POSTSAVE => [
        'postSave',
      ],
      FeedsEvents::CLEAN => [
        'onClean',
      ],
      FeedsEvents::INIT_CLEAR => [
        'onInitClear',
      ],
      FeedsEvents::CLEAR => [
        'onClear',
      ],
      FeedsEvents::INIT_EXPIRE => [
        'onInitExpire',
      ],
      FeedsEvents::EXPIRE => [
        'onExpire',
      ],
      FeedsEvents::IMPORT_FINISHED => [
        'onFinish',
      ],
    ];
  }

  /**
   * Acts on multiple feeds getting deleted.
   */
  public function onDelete(DeleteFeedsEvent $event) {
    $GLOBALS['feeds_test_events'][] = __METHOD__ . ' called';
  }

  /**
   * Acts on an import being initiated.
   */
  public function onInitImport(InitEvent $event) {
    $GLOBALS['feeds_test_events'][] = __METHOD__ . ' called';
  }

  /**
   * Acts on event before fetching.
   */
  public function preFetch(FetchEvent $event) {
    $GLOBALS['feeds_test_events'][] = __METHOD__ . ' called';
  }

  /**
   * Acts on fetcher result.
   */
  public function postFetch(FetchEvent $event) {
    $GLOBALS['feeds_test_events'][] = __METHOD__ . ' called';
  }

  /**
   * Acts on event before parsing.
   */
  public function preParse(ParseEvent $event) {
    $GLOBALS['feeds_test_events'][] = __METHOD__ . ' called';
  }

  /**
   * Acts on parser result.
   */
  public function postParse(ParseEvent $event) {
    $GLOBALS['feeds_test_events'][] = __METHOD__ . ' called';
  }

  /**
   * Acts on event before processing.
   */
  public function preProcess(ProcessEvent $event) {
    $GLOBALS['feeds_test_events'][] = __METHOD__ . ' called';
  }

  /**
   * Acts on process result.
   */
  public function postProcess(ProcessEvent $event) {
    $GLOBALS['feeds_test_events'][] = __METHOD__ . ' called';
  }

  /**
   * Acts on an entity before validation.
   */
  public function prevalidate(EntityEvent $event) {
    $GLOBALS['feeds_test_events'][] = __METHOD__ . ' called';
    $feed_type_id = $event
      ->getFeed()
      ->getType()
      ->id();
    switch ($feed_type_id) {
      case 'no_title':

        // A title is required, set a title on the entity to prevent validation
        // errors.
        $event
          ->getEntity()->title = 'foo';
        break;
    }
  }

  /**
   * Acts on presaving an entity.
   */
  public function preSave(EntityEvent $event) {
    $GLOBALS['feeds_test_events'][] = __METHOD__ . ' called';
    $feed_type_id = $event
      ->getFeed()
      ->getType()
      ->id();
    switch ($feed_type_id) {
      case 'import_skip':

        // We do not save the node called 'Lorem ipsum'.
        if ($event
          ->getEntity()
          ->getTitle() == 'Lorem ipsum') {
          throw new EmptyFeedException();
        }
        break;
    }
  }

  /**
   * Acts on postsaving an entity.
   */
  public function postSave(EntityEvent $event) {
    $GLOBALS['feeds_test_events'][] = __METHOD__ . ' called';
  }

  /**
   * Acts on the cleaning stage.
   */
  public function onClean(CleanEvent $event) {
    $GLOBALS['feeds_test_events'][] = __METHOD__ . ' called';
  }

  /**
   * Acts on event before deleting items begins.
   */
  public function onInitClear(InitEvent $event) {
    $GLOBALS['feeds_test_events'][] = __METHOD__ . ' called';
  }

  /**
   * Acts on event where deleting items has began.
   */
  public function onClear(ClearEvent $event) {
    $GLOBALS['feeds_test_events'][] = __METHOD__ . ' called';
  }

  /**
   * Acts on event before expiring items begins.
   */
  public function onInitExpire(InitEvent $event) {
    $GLOBALS['feeds_test_events'][] = __METHOD__ . ' called';
  }

  /**
   * Acts on event where expiring items has began.
   */
  public function onExpire(ExpireEvent $event) {
    $GLOBALS['feeds_test_events'][] = __METHOD__ . ' called';
  }

  /**
   * Acts on the completion of an import.
   */
  public function onFinish(ImportFinishedEvent $event) {
    $GLOBALS['feeds_test_events'][] = __METHOD__ . ' called';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FeedsSubscriber::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.
FeedsSubscriber::onClean public function Acts on the cleaning stage.
FeedsSubscriber::onClear public function Acts on event where deleting items has began.
FeedsSubscriber::onDelete public function Acts on multiple feeds getting deleted.
FeedsSubscriber::onExpire public function Acts on event where expiring items has began.
FeedsSubscriber::onFinish public function Acts on the completion of an import.
FeedsSubscriber::onInitClear public function Acts on event before deleting items begins.
FeedsSubscriber::onInitExpire public function Acts on event before expiring items begins.
FeedsSubscriber::onInitImport public function Acts on an import being initiated.
FeedsSubscriber::postFetch public function Acts on fetcher result.
FeedsSubscriber::postParse public function Acts on parser result.
FeedsSubscriber::postProcess public function Acts on process result.
FeedsSubscriber::postSave public function Acts on postsaving an entity.
FeedsSubscriber::preFetch public function Acts on event before fetching.
FeedsSubscriber::preParse public function Acts on event before parsing.
FeedsSubscriber::preProcess public function Acts on event before processing.
FeedsSubscriber::preSave public function Acts on presaving an entity.
FeedsSubscriber::prevalidate public function Acts on an entity before validation.