class EnsureSubscriber in Flysystem 2.0.x
Same name and namespace in other branches
- 8 src/EventSubscriber/EnsureSubscriber.php \Drupal\flysystem\EventSubscriber\EnsureSubscriber
- 3.x src/EventSubscriber/EnsureSubscriber.php \Drupal\flysystem\EventSubscriber\EnsureSubscriber
- 3.0.x src/EventSubscriber/EnsureSubscriber.php \Drupal\flysystem\EventSubscriber\EnsureSubscriber
Event listener that listens to Flysystem ensure() calls.
Hierarchy
- class \Drupal\flysystem\EventSubscriber\EnsureSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of EnsureSubscriber
1 file declares its use of EnsureSubscriber
- EnsureSubscriberTest.php in tests/
src/ Unit/ EventSubscriber/ EnsureSubscriberTest.php
1 string reference to 'EnsureSubscriber'
1 service uses EnsureSubscriber
File
- src/
EventSubscriber/ EnsureSubscriber.php, line 15
Namespace
Drupal\flysystem\EventSubscriberView source
class EnsureSubscriber implements EventSubscriberInterface {
/**
* The logger to use.
*
* @var \Psr\Log\LoggerInterface
*/
protected $logger;
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events = [];
$events[FlysystemEvents::ENSURE][] = 'onEnsure';
return $events;
}
/**
* Constructs an EnsureSubscriber object.
*
* @param \Psr\Log\LoggerInterface $logger
* The logger.
*/
public function __construct(LoggerInterface $logger) {
$this->logger = $logger;
}
/**
* Responds to FlysystemFactory::ensure().
*/
public function onEnsure(EnsureEvent $event, $event_name, EventDispatcherInterface $dispatcher) {
// We only want to log failures, since this runs frequently.
switch ($event
->getSeverity()) {
case RfcLogLevel::NOTICE:
case RfcLogLevel::INFO:
return;
}
$this->logger
->log($event
->getSeverity(), $event
->getMessage(), $event
->getContext());
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EnsureSubscriber:: |
protected | property | The logger to use. | |
EnsureSubscriber:: |
public static | function | ||
EnsureSubscriber:: |
public | function | Responds to FlysystemFactory::ensure(). | |
EnsureSubscriber:: |
public | function | Constructs an EnsureSubscriber object. |