You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
649 B
33 lines
649 B
<?php |
|
|
|
declare(strict_types=1); |
|
|
|
namespace PhpMyAdmin\Twig; |
|
|
|
use PhpMyAdmin\Theme; |
|
use Twig\Extension\AbstractExtension; |
|
use Twig\TwigFunction; |
|
|
|
final class AssetExtension extends AbstractExtension |
|
{ |
|
/** |
|
* @return TwigFunction[] |
|
*/ |
|
public function getFunctions() |
|
{ |
|
return [ |
|
new TwigFunction('image', [$this, 'getImagePath']), |
|
]; |
|
} |
|
|
|
public function getImagePath(?string $filename = null, ?string $fallback = null): string |
|
{ |
|
global $theme; |
|
|
|
if (! $theme instanceof Theme) { |
|
return ''; |
|
} |
|
|
|
return $theme->getImgPath($filename, $fallback); |
|
} |
|
}
|
|
|