You are here

class AutomatedCropProvider in Automated Crop 8

Subscribe each automated crop providers as automatic crop api provider.

Hierarchy

  • class \Drupal\automated_crop_crop_provider\EventSubscriber\AutomatedCropProvider implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of AutomatedCropProvider

1 string reference to 'AutomatedCropProvider'
automated_crop_crop_provider.services.yml in modules/automated_crop_crop_provider/automated_crop_crop_provider.services.yml
modules/automated_crop_crop_provider/automated_crop_crop_provider.services.yml
1 service uses AutomatedCropProvider
automated_crop.provider.subscriber in modules/automated_crop_crop_provider/automated_crop_crop_provider.services.yml
Drupal\automated_crop_crop_provider\EventSubscriber\AutomatedCropProvider

File

modules/automated_crop_crop_provider/src/EventSubscriber/AutomatedCropProvider.php, line 12

Namespace

Drupal\automated_crop_crop_provider\EventSubscriber
View source
class AutomatedCropProvider implements EventSubscriberInterface {

  /**
   * Register automated crop plugins as crop api providers.
   *
   * @param \Drupal\crop\Events\AutomaticCropProviders $event
   *   The Event to process.
   */
  public function addProvider(AutomaticCropProviders $event) {
    foreach (\Drupal::service('plugin.manager.automated_crop')
      ->getProviderOptionsList() as $key => $provider) {
      $event
        ->registerProvider([
        $key => $provider
          ->render(),
      ]);
    }
  }

  /**
   * Registers the methods in this class that should be listeners.
   *
   * @return array
   *   An array of event listener definitions.
   */
  public static function getSubscribedEvents() {
    return [
      Events::AUTOMATIC_CROP_PROVIDERS => [
        [
          'addProvider',
          100,
        ],
      ],
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AutomatedCropProvider::addProvider public function Register automated crop plugins as crop api providers.
AutomatedCropProvider::getSubscribedEvents public static function Registers the methods in this class that should be listeners.