You are here

class UpdateTracking in Acquia Content Hub 8.2

Removes deleted remote entities from the publisher tracking table.

Hierarchy

  • class \Drupal\acquia_contenthub_publisher\EventSubscriber\DeleteRemoteEntity\UpdateTracking implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of UpdateTracking

1 string reference to 'UpdateTracking'
acquia_contenthub_publisher.services.yml in modules/acquia_contenthub_publisher/acquia_contenthub_publisher.services.yml
modules/acquia_contenthub_publisher/acquia_contenthub_publisher.services.yml
1 service uses UpdateTracking
update_tracking.delete_remote_entity in modules/acquia_contenthub_publisher/acquia_contenthub_publisher.services.yml
Drupal\acquia_contenthub_publisher\EventSubscriber\DeleteRemoteEntity\UpdateTracking

File

modules/acquia_contenthub_publisher/src/EventSubscriber/DeleteRemoteEntity/UpdateTracking.php, line 14

Namespace

Drupal\acquia_contenthub_publisher\EventSubscriber\DeleteRemoteEntity
View source
class UpdateTracking implements EventSubscriberInterface {

  /**
   * The publisher tracker.
   *
   * @var \Drupal\acquia_contenthub_publisher\PublisherTracker
   */
  protected $tracker;

  /**
   * The acquia_contenthub logger channel.
   *
   * @var \Drupal\Core\Logger\LoggerChannelInterface
   */
  protected $channel;

  /**
   * UpdateTracking constructor.
   *
   * @param \Drupal\acquia_contenthub_publisher\PublisherTracker $tracker
   *   The publisher tracker.
   * @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $logger_factory
   *   The logger channel factory.
   */
  public function __construct(PublisherTracker $tracker, LoggerChannelFactoryInterface $logger_factory) {
    $this->tracker = $tracker;
    $this->channel = $logger_factory
      ->get('acquia_contenthub_publisher');
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    $events[AcquiaContentHubEvents::DELETE_REMOTE_ENTITY][] = 'onDeleteRemoteEntity';
    return $events;
  }

  /**
   * Removes deleted remote entities from the publisher tracking table.
   *
   * @param \Drupal\acquia_contenthub\Event\DeleteRemoteEntityEvent $event
   *   The DeleteRemoteEntityEvent object.
   *
   * @throws \Exception
   */
  public function onDeleteRemoteEntity(DeleteRemoteEntityEvent $event) {
    if ($this->tracker
      ->get($event
      ->getUuid())) {
      $this->tracker
        ->delete($event
        ->getUuid());
      $this->channel
        ->info(sprintf("Removed tracking for entity with UUID = \"%s\".", $event
        ->getUuid()));
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
UpdateTracking::$channel protected property The acquia_contenthub logger channel.
UpdateTracking::$tracker protected property The publisher tracker.
UpdateTracking::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.
UpdateTracking::onDeleteRemoteEntity public function Removes deleted remote entities from the publisher tracking table.
UpdateTracking::__construct public function UpdateTracking constructor.