mirror of
https://github.com/getgrav/grav.git
synced 2026-03-04 11:31:43 +01:00
Add support for custom output providers like Slim Framework
This commit is contained in:
@@ -127,10 +127,16 @@ class Grav extends Container
|
||||
});
|
||||
}
|
||||
|
||||
// Set the header type
|
||||
$this->header();
|
||||
$output = $this->output;
|
||||
|
||||
// Support for custom output providers like Slim Framework.
|
||||
if (!$output instanceof \Psr\Http\Message\ResponseInterface) {
|
||||
// Set the header type
|
||||
$this->header();
|
||||
|
||||
echo $output;
|
||||
}
|
||||
|
||||
echo $this->output;
|
||||
$debugger->render();
|
||||
|
||||
$this->fireEvent('onOutputRendered');
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
namespace Grav\Common\Service;
|
||||
|
||||
use Grav\Common\Page\Page;
|
||||
use Grav\Common\Twig\Twig;
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
@@ -16,7 +18,13 @@ class OutputServiceProvider implements ServiceProviderInterface
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container['output'] = function ($c) {
|
||||
return $c['twig']->processSite($c['page']->templateFormat());
|
||||
/** @var Twig $twig */
|
||||
$twig = $c['twig'];
|
||||
|
||||
/** @var Page $page */
|
||||
$page = $c['page'];
|
||||
|
||||
return $twig->processSite($page->templateFormat());
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user