37 lines
701 B
PHP
37 lines
701 B
PHP
<?php
|
|
|
|
namespace App\Framework\Twig;
|
|
|
|
class UrlExtension extends \Twig_Extension
|
|
{
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
//private $url;
|
|
|
|
public function __construct()
|
|
{
|
|
// $this->url = $url;
|
|
}
|
|
|
|
public function getFunctions()
|
|
{
|
|
return [
|
|
//new \Twig_SimpleFunction('url', [$this, 'getUrl']),
|
|
new \Twig_SimpleFunction('explodeUrl', [$this, 'explodeUrl'])
|
|
];
|
|
}
|
|
|
|
/* public function getUrl(): string
|
|
{
|
|
return $_SERVER['REQUEST_URI'] ?? '/';
|
|
}*/
|
|
public function explodeUrl(): array
|
|
{
|
|
$url = $_SERVER['REQUEST_URI'] ?? '/';
|
|
$url_parts = explode('/', $url);
|
|
return $url_parts;
|
|
}
|
|
}
|