RenderProcessor.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * @package Grav.Common.Processors
  4. *
  5. * @copyright Copyright (C) 2015 - 2018 Trilby Media, LLC. All rights reserved.
  6. * @license MIT License; see LICENSE file for details.
  7. */
  8. namespace Grav\Common\Processors;
  9. class RenderProcessor extends ProcessorBase implements ProcessorInterface
  10. {
  11. public $id = 'render';
  12. public $title = 'Render';
  13. public function process()
  14. {
  15. $container = $this->container;
  16. $output = $container['output'];
  17. if ($output instanceof \Psr\Http\Message\ResponseInterface) {
  18. // Support for custom output providers like Slim Framework.
  19. } else {
  20. // Use internal Grav output.
  21. $container->output = $output;
  22. $container->fireEvent('onOutputGenerated');
  23. // Set the header type
  24. $container->header();
  25. echo $container->output;
  26. // remove any output
  27. $container->output = '';
  28. $this->container->fireEvent('onOutputRendered');
  29. }
  30. }
  31. }