Conditions | 6 |
Paths | 12 |
Total Lines | 19 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 42 |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | public function __invoke (Twig_Environment $env, $assetPath) |
||
10 | { |
||
11 | $globals = $env->getGlobals(); |
||
12 | |||
13 | if (is_array($assetPath) || ($assetPath instanceof \ArrayAccess)) { |
||
14 | $assetPath = $assetPath['permalink']; |
||
15 | } |
||
16 | else if (is_null($assetPath)) { |
||
17 | $assetPath = '/'; |
||
18 | } |
||
19 | |||
20 | // @TODO 1.0.0 Remove support for 'base' as it's been deprecated |
||
|
|||
21 | $base = (array_key_exists('base', $globals['site'])) ? $globals['site']['base'] : $globals['site']['baseurl']; |
||
22 | |||
23 | $baseURL = (empty($base)) ? '/' : '/' . trim($base, '/') . '/'; |
||
24 | $url = ltrim($assetPath, '/'); |
||
25 | |||
26 | return ($baseURL . $url); |
||
27 | } |
||
28 | |||
35 | } |