mirror of
https://github.com/flextype/flextype.git
synced 2025-08-06 13:16:45 +02:00
feat(icon-plugin): remove icon twig extension from admin plugin #371
This commit is contained in:
@@ -30,10 +30,6 @@ $flextype->registry->set('admin_navigation.settings.api', ['title' => __('admin_
|
||||
// Add Global Vars Admin Twig Extension
|
||||
$flextype->view->addExtension(new GlobalVarsAdminTwigExtension($flextype));
|
||||
|
||||
// Add Icon Admin Twig Extension
|
||||
$flextype->view->addExtension(new IconAdminTwigExtension($flextype));
|
||||
|
||||
|
||||
$flextype['DashboardController'] = static function ($container) {
|
||||
return new DashboardController($container);
|
||||
};
|
||||
|
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype (http://flextype.org)
|
||||
* Founded by Sergey Romanenko and maintained by Flextype Community.
|
||||
*/
|
||||
|
||||
namespace Flextype;
|
||||
|
||||
use Flextype\Component\Filesystem\Filesystem;
|
||||
use Twig_Extension;
|
||||
use Twig_SimpleFunction;
|
||||
|
||||
class IconAdminTwigExtension extends Twig_Extension
|
||||
{
|
||||
/**
|
||||
* Callback for twig.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getFunctions() : array
|
||||
{
|
||||
return [
|
||||
new Twig_SimpleFunction('icon', [$this, 'icon'], ['is_safe' => ['html']])
|
||||
];
|
||||
}
|
||||
|
||||
public function icon($value)
|
||||
{
|
||||
$icon_parts = explode(" ", $value);
|
||||
|
||||
if ($icon_parts[0] == 'fas') {
|
||||
$icon_category = 'solid';
|
||||
} elseif ($icon_parts[0] == 'fab') {
|
||||
$icon_category = 'brands';
|
||||
} elseif ($icon_parts[0] == 'far') {
|
||||
$icon_category = 'regular';
|
||||
}
|
||||
|
||||
$icon_name = str_replace("fa-", "", $icon_parts[1]);
|
||||
|
||||
$icon = Filesystem::read(PATH['plugins'] . '/admin/assets/dist/fontawesome/svgs/' . $icon_category . '/' . $icon_name . '.svg');
|
||||
|
||||
return $icon;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user