You are here

class RequestSubscriber in Raven: Sentry Integration 8.2

Same name and namespace in other branches
  1. 3.x src/EventSubscriber/RequestSubscriber.php \Drupal\raven\EventSubscriber\RequestSubscriber

Initializes Raven logger if fatal error logging is enabled.

Hierarchy

  • class \Drupal\raven\EventSubscriber\RequestSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface, \Symfony\Component\DependencyInjection\ContainerAwareInterface uses \Symfony\Component\DependencyInjection\ContainerAwareTrait

Expanded class hierarchy of RequestSubscriber

1 string reference to 'RequestSubscriber'
raven.services.yml in ./raven.services.yml
raven.services.yml
1 service uses RequestSubscriber
raven.request_subscriber in ./raven.services.yml
Drupal\raven\EventSubscriber\RequestSubscriber

File

src/EventSubscriber/RequestSubscriber.php, line 14

Namespace

Drupal\raven\EventSubscriber
View source
class RequestSubscriber implements EventSubscriberInterface, ContainerAwareInterface {
  use ContainerAwareTrait;

  /**
   * The config factory.
   *
   * @var \Drupal\Core\Config\ConfigFactoryInterface
   */
  protected $configFactory;

  /**
   * Constructs a new Raven RequestSubscriber.
   *
   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
   *   The configuration factory.
   */
  public function __construct(ConfigFactoryInterface $config_factory) {
    $this->configFactory = $config_factory;
  }

  /**
   * Initializes Raven logger if fatal error logging is enabled.
   */
  public function onRequest() {
    if ($this->configFactory
      ->get('raven.settings')
      ->get('fatal_error_handler')) {
      $this->container
        ->get('logger.raven');
    }
  }

  /**
   * Registers the methods in this class that should be listeners.
   *
   * @return array
   *   An array of event listener definitions.
   */
  public static function getSubscribedEvents() {
    $events[KernelEvents::REQUEST][] = [
      'onRequest',
      222,
    ];
    return $events;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RequestSubscriber::$configFactory protected property The config factory.
RequestSubscriber::getSubscribedEvents public static function Registers the methods in this class that should be listeners.
RequestSubscriber::onRequest public function Initializes Raven logger if fatal error logging is enabled.
RequestSubscriber::__construct public function Constructs a new Raven RequestSubscriber.