You are here

class DefaultException in Acquia Content Hub 8.2

Default exceptions for import failures.

@package Drupal\acquia_contenthub\EventSubscriber\ImportFailure

Hierarchy

  • class \Drupal\acquia_contenthub\EventSubscriber\ImportFailure\DefaultException implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of DefaultException

1 string reference to 'DefaultException'
acquia_contenthub.services.yml in ./acquia_contenthub.services.yml
acquia_contenthub.services.yml
1 service uses DefaultException
acquia_contenthub.import_failure.default_exception in ./acquia_contenthub.services.yml
Drupal\acquia_contenthub\EventSubscriber\ImportFailure\DefaultException

File

src/EventSubscriber/ImportFailure/DefaultException.php, line 14

Namespace

Drupal\acquia_contenthub\EventSubscriber\ImportFailure
View source
class DefaultException implements EventSubscriberInterface {

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

  /**
   * A default failure exception creator.
   *
   * @param \Drupal\acquia_contenthub\Event\FailedImportEvent $event
   *   The failure event.
   */
  public function onImportFailure(FailedImportEvent $event) {
    if (!$event
      ->hasException()) {
      $exception = new \Exception(sprintf("Failed to import. %d of %d imported", $event
        ->getCount(), count($event
        ->getCdf()
        ->getEntities())));
      $event
        ->setException($exception);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DefaultException::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.
DefaultException::onImportFailure public function A default failure exception creator.