Skip to content

Commit

Permalink
Update PjaxServiceProvider.php
Browse files Browse the repository at this point in the history
  • Loading branch information
vtalbot committed Dec 10, 2013
1 parent 41c0387 commit 06ce370
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/VTalbot/Pjax/PjaxServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,20 @@ public function register()
$app = $this->app;

$this->app->after(function(Request $request, Response $response) use ($app) {
if ($response->isRedirection())
{
return $response;
}

if ($request->server->get('HTTP_X_PJAX')) {
$crawler = new Crawler($response->getContent());
$response->setContent($crawler->filter($request->server->get('HTTP_X_PJAX_CONTAINER'))->html());

$html = $crawler->filter($request->server->get('HTTP_X_PJAX_CONTAINER'))->html();
$title = $crawler->filter('head title')->html();

$response->setContent($title . $html);

$response->header('X-PJAX-URL', $request->getRequestUri());
}

return $response;
Expand Down

0 comments on commit 06ce370

Please sign in to comment.