Skip to content

Instantly share code, notes, and snippets.

@henrikbjorn
Created July 28, 2011 07:29
Show Gist options
  • Save henrikbjorn/1111154 to your computer and use it in GitHub Desktop.
Save henrikbjorn/1111154 to your computer and use it in GitHub Desktop.
<?php
namespace Diveshare\DiveshareBundle\Templating;
/**
* Additional helpful methods that is needed in templates.
*
* @package DiveshareBundle
*/
class GlobalVariables extends \Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables
{
/**
* For use in a twig template with `{% extends app.pjax ? 'empty.twig' : 'base.twig' %}` so it is possible to serve up a chromeless
* rendering.
*
* @return Boolean
*/
public function isPjax()
{
if ($request = $this->getRequest() && $request->server->has('X-PJAX')) {
return true;
}
return false;
}
}
@stof
Copy link

stof commented Jul 28, 2011

better than replacing the global variable set by the framework (as you cannot do it several times): register a new one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment