You are here

class UpdateRefreshSubscriber in Automatic Updates 8.2

Clears stale update data once a staged update has been committed.

Hierarchy

  • class \Drupal\automatic_updates\Event\UpdateRefreshSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of UpdateRefreshSubscriber

1 string reference to 'UpdateRefreshSubscriber'
automatic_updates.services.yml in ./automatic_updates.services.yml
automatic_updates.services.yml
1 service uses UpdateRefreshSubscriber
automatic_updates.update_refresh_subscriber in ./automatic_updates.services.yml
Drupal\automatic_updates\Event\UpdateRefreshSubscriber

File

src/Event/UpdateRefreshSubscriber.php, line 12

Namespace

Drupal\automatic_updates\Event
View source
class UpdateRefreshSubscriber implements EventSubscriberInterface {

  /**
   * The update manager service.
   *
   * @var \Drupal\update\UpdateManagerInterface
   */
  protected $updateManager;

  /**
   * Constructs an UpdateRefreshSubscriber object.
   *
   * @param \Drupal\update\UpdateManagerInterface $update_manager
   *   The update manager service.
   */
  public function __construct(UpdateManagerInterface $update_manager) {
    $this->updateManager = $update_manager;
  }

  /**
   * Clears stale update data.
   */
  public function clearData() : void {
    $this->updateManager
      ->refreshUpdateData();
    update_storage_clear();
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    return [
      AutomaticUpdatesEvents::POST_COMMIT => [
        'clearData',
        1000,
      ],
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
UpdateRefreshSubscriber::$updateManager protected property The update manager service.
UpdateRefreshSubscriber::clearData public function Clears stale update data.
UpdateRefreshSubscriber::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.
UpdateRefreshSubscriber::__construct public function Constructs an UpdateRefreshSubscriber object.