You are here

ReferenceablePluginTypesSubscriber.php in Commerce Recurring Framework 8

File

src/EventSubscriber/ReferenceablePluginTypesSubscriber.php
View source
<?php

namespace Drupal\commerce_recurring\EventSubscriber;

use Drupal\commerce\Event\CommerceEvents;
use Drupal\commerce\Event\ReferenceablePluginTypesEvent;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class ReferenceablePluginTypesSubscriber implements EventSubscriberInterface {
  use StringTranslationTrait;

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    $events[CommerceEvents::REFERENCEABLE_PLUGIN_TYPES][] = [
      'onPluginTypes',
    ];
    return $events;
  }

  /**
   * Registers the 'commerce_subscription_type' plugin type as referenceable.
   *
   * @param \Drupal\commerce\Event\ReferenceablePluginTypesEvent $event
   *   The event.
   */
  public function onPluginTypes(ReferenceablePluginTypesEvent $event) {
    $types = $event
      ->getPluginTypes();
    $types['commerce_subscription_type'] = $this
      ->t('Subscription type');
    $types['commerce_prorater'] = $this
      ->t('Prorater');
    $event
      ->setPluginTypes($types);
  }

}