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'
1 service uses DefaultException
File
- src/
EventSubscriber/ ImportFailure/ DefaultException.php, line 14
Namespace
Drupal\acquia_contenthub\EventSubscriber\ImportFailureView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DefaultException:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
DefaultException:: |
public | function | A default failure exception creator. |