You are here

class ConfigurationUpdateSubscriber in Update helper 8

Same name and namespace in other branches
  1. 2.x modules/update_helper_checklist/src/Events/ConfigurationUpdateSubscriber.php \Drupal\update_helper_checklist\Events\ConfigurationUpdateSubscriber

Configuration update subscriber.

@package Drupal\update_helper_checklist\Events

Hierarchy

  • class \Drupal\update_helper_checklist\Events\ConfigurationUpdateSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of ConfigurationUpdateSubscriber

1 string reference to 'ConfigurationUpdateSubscriber'
update_helper_checklist.services.yml in modules/update_helper_checklist/update_helper_checklist.services.yml
modules/update_helper_checklist/update_helper_checklist.services.yml
1 service uses ConfigurationUpdateSubscriber
update_helper_checklist.configuration_update_subscriber in modules/update_helper_checklist/update_helper_checklist.services.yml
Drupal\update_helper_checklist\Events\ConfigurationUpdateSubscriber

File

modules/update_helper_checklist/src/Events/ConfigurationUpdateSubscriber.php, line 15

Namespace

Drupal\update_helper_checklist\Events
View source
class ConfigurationUpdateSubscriber implements EventSubscriberInterface {

  /**
   * Update checklist service.
   *
   * @var \Drupal\update_helper_checklist\UpdateChecklist
   */
  protected $updateChecklist;

  /**
   * ConfigurationUpdateSubscriber constructor.
   *
   * @param \Drupal\update_helper_checklist\UpdateChecklist $update_checklist
   *   Update checklist service.
   */
  public function __construct(UpdateChecklist $update_checklist) {
    $this->updateChecklist = $update_checklist;
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    return [
      UpdateHelperEvents::CONFIGURATION_UPDATE => [
        [
          'onConfigurationUpdate',
          10,
        ],
      ],
    ];
  }

  /**
   * Handles on configuration update event.
   *
   * @param \Drupal\update_helper\Events\ConfigurationUpdateEvent $event
   *   Configuration update event.
   *
   * @throws \Drupal\Core\Entity\EntityStorageException
   */
  public function onConfigurationUpdate(ConfigurationUpdateEvent $event) {
    if ($event
      ->isSuccessful()) {
      $this->updateChecklist
        ->markUpdatesSuccessful([
        $event
          ->getModule() => [
          $event
            ->getUpdateName(),
        ],
      ]);
    }
    else {
      $this->updateChecklist
        ->markUpdatesFailed([
        $event
          ->getModule() => [
          $event
            ->getUpdateName(),
        ],
      ]);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigurationUpdateSubscriber::$updateChecklist protected property Update checklist service.
ConfigurationUpdateSubscriber::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.
ConfigurationUpdateSubscriber::onConfigurationUpdate public function Handles on configuration update event.
ConfigurationUpdateSubscriber::__construct public function ConfigurationUpdateSubscriber constructor.