You are here

class DefaultStubCleanup in Acquia Content Hub 8.2

Cleans up default stubs after import.

@package Drupal\acquia_contenthub\EventSubscriber\CleanupStubs

Hierarchy

  • class \Drupal\acquia_contenthub\EventSubscriber\CleanupStubs\DefaultStubCleanup implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of DefaultStubCleanup

1 string reference to 'DefaultStubCleanup'
acquia_contenthub.services.yml in ./acquia_contenthub.services.yml
acquia_contenthub.services.yml
1 service uses DefaultStubCleanup
default.cleanup_stubs in ./acquia_contenthub.services.yml
Drupal\acquia_contenthub\EventSubscriber\CleanupStubs\DefaultStubCleanup

File

src/EventSubscriber/CleanupStubs/DefaultStubCleanup.php, line 14

Namespace

Drupal\acquia_contenthub\EventSubscriber\CleanupStubs
View source
class DefaultStubCleanup implements EventSubscriberInterface {

  /**
   * Get subscribed events and add onStubsCleanup for default stubs.
   *
   * @return array
   *   Array of $events.
   */
  public static function getSubscribedEvents() {
    $events = [];
    $events[AcquiaContentHubEvents::CLEANUP_STUBS][] = 'onStubsCleanup';
    return $events;
  }

  /**
   * By default, we delete all stubs.
   *
   * @param \Drupal\acquia_contenthub\Event\CleanUpStubsEvent $event
   *   The cleanup stubs $event.
   *
   * @see \Drupal\acquia_contenthub\EventSubscriber\CleanupStubs\DefaultStubCleanup
   * @see \Drupal\acquia_contenthub\StubTracker::cleanUp
   */
  public function onStubsCleanup(CleanUpStubsEvent $event) {
    if (!$event
      ->getStack()
      ->hasDependency($event
      ->getEntity()
      ->uuid())) {
      $event
        ->deleteStub();
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DefaultStubCleanup::getSubscribedEvents public static function Get subscribed events and add onStubsCleanup for default stubs.
DefaultStubCleanup::onStubsCleanup public function By default, we delete all stubs.