|
|
@@ -47,22 +47,22 @@ class TwigExtension extends AbstractExtension |
|
|
|
protected AdminUrlGenerator $adminUrlGenerator; |
|
|
|
|
|
|
|
public function __construct( |
|
|
|
KernelInterface $kernel, |
|
|
|
ParameterBagInterface $parameterBag, |
|
|
|
CacheManager $cacheManager, |
|
|
|
EntityManagerInterface $entityManager, |
|
|
|
RequestStack $requestStack, |
|
|
|
UrlGeneratorInterface $router, |
|
|
|
TranslatorInterface $translator, |
|
|
|
TranslatorAdmin $translatorAdmin, |
|
|
|
ReminderStore $reminderStore, |
|
|
|
Security $security, |
|
|
|
FormFactoryInterface $formFactory, |
|
|
|
StringComponent $stringComponent, |
|
|
|
MetaComponent $metaComponent, |
|
|
|
DateComponent $dateComponent, |
|
|
|
FileComponent $fileComponent, |
|
|
|
AdminUrlGenerator $adminUrlGenerator |
|
|
|
KernelInterface $kernel, |
|
|
|
ParameterBagInterface $parameterBag, |
|
|
|
CacheManager $cacheManager, |
|
|
|
EntityManagerInterface $entityManager, |
|
|
|
RequestStack $requestStack, |
|
|
|
UrlGeneratorInterface $router, |
|
|
|
TranslatorInterface $translator, |
|
|
|
TranslatorAdmin $translatorAdmin, |
|
|
|
ReminderStore $reminderStore, |
|
|
|
Security $security, |
|
|
|
FormFactoryInterface $formFactory, |
|
|
|
StringComponent $stringComponent, |
|
|
|
MetaComponent $metaComponent, |
|
|
|
DateComponent $dateComponent, |
|
|
|
FileComponent $fileComponent, |
|
|
|
AdminUrlGenerator $adminUrlGenerator |
|
|
|
) { |
|
|
|
$this->kernel = $kernel; |
|
|
|
$this->parameterBag = $parameterBag; |
|
|
@@ -85,19 +85,20 @@ class TwigExtension extends AbstractExtension |
|
|
|
public function getFunctions() |
|
|
|
{ |
|
|
|
return [ |
|
|
|
new TwigFunction('sov_liip', [$this, 'liip']), |
|
|
|
new TwigFunction('liip', [$this, 'liip']), |
|
|
|
new TwigFunction('sov_get_by_devalias', [$this, 'getByDevAlias']), |
|
|
|
new TwigFunction('sov_parameter', [$this, 'getParameter']), |
|
|
|
new TwigFunction('sov_homepage_route', [$this, 'getHomepageRoute']), |
|
|
|
new TwigFunction('lc_format_price', [$this, 'formatPrice']), |
|
|
|
new TwigFunction('die', [$this, 'die']), |
|
|
|
new TwigFunction('get_form_newsletter', [$this, 'getFormNewsletter']), |
|
|
|
new TwigFunction('sov_limit_text', [$this, 'limitText']), |
|
|
|
new TwigFunction('day_by_number', [$this, 'getDayByNumber']), |
|
|
|
new TwigFunction('user_current', [$this, 'getUserCurrent']), |
|
|
|
new TwigFunction('ea_url_short', [$this, 'generateEaUrl']), |
|
|
|
new TwigFunction('is_instance_of', [$this, 'isInstanceOf']), |
|
|
|
new TwigFunction('sov_liip', [$this, 'liip']), |
|
|
|
new TwigFunction('liip', [$this, 'liip']), |
|
|
|
new TwigFunction('sov_get_by_devalias', [$this, 'getByDevAlias']), |
|
|
|
new TwigFunction('sov_parameter', [$this, 'getParameter']), |
|
|
|
new TwigFunction('sov_homepage_route', [$this, 'getHomepageRoute']), |
|
|
|
new TwigFunction('lc_format_price', [$this, 'formatPrice']), |
|
|
|
new TwigFunction('die', [$this, 'die']), |
|
|
|
new TwigFunction('get_form_newsletter', [$this, 'getFormNewsletter']), |
|
|
|
new TwigFunction('sov_limit_text', [$this, 'limitText']), |
|
|
|
new TwigFunction('day_by_number', [$this, 'getDayByNumber']), |
|
|
|
new TwigFunction('user_current', [$this, 'getUserCurrent']), |
|
|
|
new TwigFunction('ea_url_short', [$this, 'generateEaUrl']), |
|
|
|
new TwigFunction('is_instance_of', [$this, 'isInstanceOf']), |
|
|
|
new TwigFunction('logo_admin', [$this, 'getLogoAdmin']), |
|
|
|
]; |
|
|
|
} |
|
|
|
|
|
|
@@ -109,12 +110,12 @@ class TwigExtension extends AbstractExtension |
|
|
|
public function getFilters() |
|
|
|
{ |
|
|
|
return [ |
|
|
|
new TwigFilter('uc_first', [$this, 'ucFirst']), |
|
|
|
new TwigFilter('format_price', [$this, 'formatPrice']), |
|
|
|
new TwigFilter('sov_cache', [$this, 'sovCache']), |
|
|
|
new TwigFilter('slugify', [$this, 'slugify']), |
|
|
|
new TwigFilter('md5', [$this, 'md5']), |
|
|
|
new TwigFilter('rot13', [$this, 'rot13']), |
|
|
|
new TwigFilter('uc_first', [$this, 'ucFirst']), |
|
|
|
new TwigFilter('format_price', [$this, 'formatPrice']), |
|
|
|
new TwigFilter('sov_cache', [$this, 'sovCache']), |
|
|
|
new TwigFilter('slugify', [$this, 'slugify']), |
|
|
|
new TwigFilter('md5', [$this, 'md5']), |
|
|
|
new TwigFilter('rot13', [$this, 'rot13']), |
|
|
|
]; |
|
|
|
} |
|
|
|
|
|
|
@@ -128,8 +129,8 @@ class TwigExtension extends AbstractExtension |
|
|
|
$reflection = new \ReflectionClass($entity); |
|
|
|
$interfaceNameArray = $reflection->getInterfaceNames(); |
|
|
|
|
|
|
|
foreach($interfaceNameArray as $interfaceNameEntity) { |
|
|
|
if(strpos($interfaceNameEntity, $interfaceName) !== false) { |
|
|
|
foreach ($interfaceNameArray as $interfaceNameEntity) { |
|
|
|
if (strpos($interfaceNameEntity, $interfaceName) !== false) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
@@ -207,8 +208,12 @@ class TwigExtension extends AbstractExtension |
|
|
|
return $this->security->getUser(); |
|
|
|
} |
|
|
|
|
|
|
|
public function generateEaUrl(string $controller =null, string $action=null, int $entityId=null, array $extraParam = array()): string |
|
|
|
{ |
|
|
|
public function generateEaUrl( |
|
|
|
string $controller = null, |
|
|
|
string $action = null, |
|
|
|
int $entityId = null, |
|
|
|
array $extraParam = array() |
|
|
|
): string { |
|
|
|
$adminUrlGenerator = $this->adminUrlGenerator; |
|
|
|
|
|
|
|
if ($controller) { |
|
|
@@ -220,8 +225,8 @@ class TwigExtension extends AbstractExtension |
|
|
|
|
|
|
|
$adminUrlGenerator->setEntityId($entityId); |
|
|
|
|
|
|
|
if($extraParam){ |
|
|
|
foreach ($extraParam as $key=>$value) { |
|
|
|
if ($extraParam) { |
|
|
|
foreach ($extraParam as $key => $value) { |
|
|
|
$adminUrlGenerator->set($key, $value); |
|
|
|
} |
|
|
|
} |
|
|
@@ -232,4 +237,9 @@ class TwigExtension extends AbstractExtension |
|
|
|
{ |
|
|
|
return md5($text); |
|
|
|
} |
|
|
|
|
|
|
|
public function getLogoAdmin(): string |
|
|
|
{ |
|
|
|
return '<img class="logo-admin" src="assets/img/' . $this->getParameter('app.admin.logo') . '" >'; |
|
|
|
} |
|
|
|
} |