Created
June 24, 2019 07:47
-
-
Save A-312/60db1d47cfe7c8163188c25d1cd80b7f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Core\Bundle\Twig\TwigExtension; | |
use Core\Kernel\Kernel; | |
class assetExtension extends \Twig_Extension { | |
public function getFunctions() { | |
return array( | |
new \Twig_SimpleFunction("asset", array($this, "asset")) | |
); | |
} | |
public function asset($url) { | |
$kernel = Kernel::getCore(); | |
$res = $kernel->getConfig()["res"]; | |
$router = ($kernel->isDevEnvironment()) ? "/res_dev.php" : ""; | |
return $res["scheme"]."://".$res["host"].$router.(($url[0]!="/")?"/":"").$url; | |
} | |
public function getName() { | |
return "assetExtension"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment