You are here

class Purge in Acquia Content Hub 8.2

Same name in this branch
  1. 8.2 modules/acquia_contenthub_subscriber/src/EventSubscriber/HandleWebhook/Purge.php \Drupal\acquia_contenthub_subscriber\EventSubscriber\HandleWebhook\Purge
  2. 8.2 modules/acquia_contenthub_publisher/src/EventSubscriber/HandleWebhook/Purge.php \Drupal\acquia_contenthub_publisher\EventSubscriber\HandleWebhook\Purge

Class PurgePublisher.

Reacts on "purge" webhook and purges the publish export tracking database table and the export queue.

@package Drupal\acquia_contenthub_publisher\EventSubscriber\HandleWebhook

Hierarchy

  • class \Drupal\acquia_contenthub\EventSubscriber\HandleWebhook\PurgeBase implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
    • class \Drupal\acquia_contenthub_publisher\EventSubscriber\HandleWebhook\Purge

Expanded class hierarchy of Purge

1 file declares its use of Purge
PurgeTest.php in tests/src/Kernel/EventSubscriber/HandleWebhook/PurgeTest.php
2 string references to 'Purge'
acquia_contenthub_publisher.services.yml in modules/acquia_contenthub_publisher/acquia_contenthub_publisher.services.yml
modules/acquia_contenthub_publisher/acquia_contenthub_publisher.services.yml
ContentHubExportQueueForm::buildForm in modules/acquia_contenthub_publisher/src/Form/ContentHubExportQueueForm.php
Form constructor.
1 service uses Purge
acquia_contenthub_publisher.handle_webhook.purge in modules/acquia_contenthub_publisher/acquia_contenthub_publisher.services.yml
Drupal\acquia_contenthub_publisher\EventSubscriber\HandleWebhook\Purge

File

modules/acquia_contenthub_publisher/src/EventSubscriber/HandleWebhook/Purge.php, line 18

Namespace

Drupal\acquia_contenthub_publisher\EventSubscriber\HandleWebhook
View source
class Purge extends PurgeBase {

  /**
   * The Database connection.
   *
   * @var \Drupal\Core\Database\Connection
   */
  protected $database;

  /**
   * Purge constructor.
   *
   * @param \Drupal\Core\Queue\QueueFactory $queue_factory
   *   The queue factory.
   * @param \Drupal\Core\Logger\LoggerChannelInterface $logger_channel
   *   The logger channel.
   * @param \Drupal\Core\Database\Connection $database
   *   The database connection.
   */
  public function __construct(QueueFactory $queue_factory, LoggerChannelInterface $logger_channel, Connection $database) {
    parent::__construct($queue_factory, $logger_channel);
    $this->database = $database;
  }

  /**
   * {@inheritdoc}
   */
  protected function getQueueName() : string {
    return 'acquia_contenthub_publish_export';
  }

  /**
   * Reacts on "purge successful" webhook.
   *
   * @see \Drupal\acquia_contenthub\EventSubscriber\HandleWebhook\PurgeBase::onHandleWebhook()
   */
  protected function onPurgeSuccessful() {
    parent::onPurgeSuccessful();
    $this->database
      ->truncate('acquia_contenthub_publisher_export_tracking')
      ->execute();
    $this->logger
      ->info('Database table "acquia_contenthub_publisher_export_tracking" has been truncated successfully.');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Purge::$database protected property The Database connection.
Purge::getQueueName protected function Returns the queue name to delete. Overrides PurgeBase::getQueueName
Purge::onPurgeSuccessful protected function Reacts on "purge successful" webhook. Overrides PurgeBase::onPurgeSuccessful
Purge::__construct public function Purge constructor. Overrides PurgeBase::__construct
PurgeBase::$logger protected property The logger service.
PurgeBase::$queue protected property The Queue.
PurgeBase::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.
PurgeBase::onHandleWebhook public function On handle webhook event.
PurgeBase::PURGE protected constant The webhook's "purge" event name.