/usr/share/php/Symfony/Bundle/TwigBundle/Extension/AssetsExtension.php is in php-symfony-twig-bundle 2.3.21+dfsg-4+deb8u3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | <?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\TwigBundle\Extension;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Twig extension for Symfony assets helper
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class AssetsExtension extends \Twig_Extension
{
private $container;
public function __construct(ContainerInterface $container)
{
$this->container = $container;
}
/**
* Returns a list of functions to add to the existing list.
*
* @return array An array of functions
*/
public function getFunctions()
{
return array(
new \Twig_SimpleFunction('asset', array($this, 'getAssetUrl')),
new \Twig_SimpleFunction('assets_version', array($this, 'getAssetsVersion')),
);
}
/**
* Returns the public path of an asset.
*
* Absolute paths (i.e. http://...) are returned unmodified.
*
* @param string $path A public path
* @param string $packageName The name of the asset package to use
*
* @return string A public path which takes into account the base path and URL path
*/
public function getAssetUrl($path, $packageName = null)
{
return $this->container->get('templating.helper.assets')->getUrl($path, $packageName);
}
/**
* Returns the version of the assets in a package.
*
* @param string $packageName
*
* @return int
*/
public function getAssetsVersion($packageName = null)
{
return $this->container->get('templating.helper.assets')->getVersion($packageName);
}
/**
* Returns the name of the extension.
*
* @return string The extension name
*/
public function getName()
{
return 'assets';
}
}
|