SchedulerProcessor.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * @package Grav\Common\Processors
  4. *
  5. * @copyright Copyright (c) 2015 - 2023 Trilby Media, LLC. All rights reserved.
  6. * @license MIT License; see LICENSE file for details.
  7. */
  8. namespace Grav\Common\Processors;
  9. use RocketTheme\Toolbox\Event\Event;
  10. use Psr\Http\Message\ResponseInterface;
  11. use Psr\Http\Message\ServerRequestInterface;
  12. use Psr\Http\Server\RequestHandlerInterface;
  13. /**
  14. * Class SchedulerProcessor
  15. * @package Grav\Common\Processors
  16. */
  17. class SchedulerProcessor extends ProcessorBase
  18. {
  19. /** @var string */
  20. public $id = '_scheduler';
  21. /** @var string */
  22. public $title = 'Scheduler';
  23. /**
  24. * @param ServerRequestInterface $request
  25. * @param RequestHandlerInterface $handler
  26. * @return ResponseInterface
  27. */
  28. public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
  29. {
  30. $this->startTimer();
  31. $scheduler = $this->container['scheduler'];
  32. $this->container->fireEvent('onSchedulerInitialized', new Event(['scheduler' => $scheduler]));
  33. $this->stopTimer();
  34. return $handler->handle($request);
  35. }
  36. }