Browse Source

Refactoring frontend

develop
Guillaume 3 years ago
parent
commit
63a626df1c
3 changed files with 25 additions and 17 deletions
  1. +5
    -0
      Repository/Site/SiteStore.php
  2. +5
    -5
      Twig/MetaTwigExtension.php
  3. +15
    -12
      Twig/TwigExtension.php

+ 5
- 0
Repository/Site/SiteStore.php View File

{ {
return $query; return $query;
} }

public function getOneDefault()
{
return $this->getOneByDevAlias('default');
}
} }

+ 5
- 5
Twig/MetaTwigExtension.php View File

return []; return [];
} }


public function getMetaTitle($entity): string
public function getMetaTitle($entity): ?string
{ {
return $this->metaComponent->getMetaTitle($entity); return $this->metaComponent->getMetaTitle($entity);
} }


public function getMetaDescription($entity): string
public function getMetaDescription($entity): ?string
{ {
return $this->metaComponent->getMetaDescription($entity); return $this->metaComponent->getMetaDescription($entity);
} }


public function getOpenGraphTitle($entity): string
public function getOpenGraphTitle($entity): ?string
{ {
return $this->metaComponent->getOpenGraphTitle($entity); return $this->metaComponent->getOpenGraphTitle($entity);
} }


public function getOpenGraphDescription($entity): string
public function getOpenGraphDescription($entity): ?string
{ {
return $this->metaComponent->getOpenGraphDescription($entity); return $this->metaComponent->getOpenGraphDescription($entity);
} }


public function getOpenGraphImage($entity): string
public function getOpenGraphImage($entity): ?string
{ {
return $this->metaComponent->getOpenGraphImage($entity); return $this->metaComponent->getOpenGraphImage($entity);
} }

+ 15
- 12
Twig/TwigExtension.php View File

use Lc\SovBundle\Component\MetaComponent; use Lc\SovBundle\Component\MetaComponent;
use Lc\SovBundle\Component\StringComponent; use Lc\SovBundle\Component\StringComponent;
use Lc\SovBundle\Form\Newsletter\NewsletterType; use Lc\SovBundle\Form\Newsletter\NewsletterType;
use Lc\SovBundle\Model\File\FileInterface;
use Lc\SovBundle\Repository\Reminder\ReminderStore; use Lc\SovBundle\Repository\Reminder\ReminderStore;
use Lc\SovBundle\Translation\TranslatorAdmin; use Lc\SovBundle\Translation\TranslatorAdmin;
use Liip\ImagineBundle\Imagine\Cache\CacheManager; use Liip\ImagineBundle\Imagine\Cache\CacheManager;


class TwigExtension extends AbstractExtension class TwigExtension extends AbstractExtension
{ {
protected $em;
protected $kernel;
protected $parameterBag;
protected $cacheManager;
protected $requestStack;
protected $router;
protected $translator;
protected $translatorAdmin;
protected $reminderStore;
protected $security;
protected EntityManagerInterface $em;
protected KernelInterface $kernel;
protected ParameterBagInterface $parameterBag;
protected CacheManager $cacheManager;
protected RequestStack $requestStack;
protected UrlGeneratorInterface $router;
protected TranslatorInterface $translator;
protected TranslatorAdmin $translatorAdmin;
protected ReminderStore $reminderStore;
protected Security $security;
protected FormFactoryInterface $formFactory; protected FormFactoryInterface $formFactory;
protected StringComponent $stringComponent; protected StringComponent $stringComponent;
protected MetaComponent $metaComponent;


public function __construct( public function __construct(
KernelInterface $kernel, KernelInterface $kernel,
{ {
return [ return [
new TwigFunction('sov_liip', [$this, 'liip']), new TwigFunction('sov_liip', [$this, 'liip']),
new TwigFunction('liip', [$this, 'liip']),
new TwigFunction('sov_get_by_devalias', [$this, 'getByDevAlias']), new TwigFunction('sov_get_by_devalias', [$this, 'getByDevAlias']),
new TwigFunction('sov_parameter', [$this, 'getParameter']), new TwigFunction('sov_parameter', [$this, 'getParameter']),
new TwigFunction('sov_homepage_route', [$this, 'getHomepageRoute']), new TwigFunction('sov_homepage_route', [$this, 'getHomepageRoute']),
$fileManagerFolder = substr($this->getFileManagerFolder(), 1); $fileManagerFolder = substr($this->getFileManagerFolder(), 1);


if (strpos($path, $fileManagerFolder) === false) { if (strpos($path, $fileManagerFolder) === false) {
$path = $fileManagerFolder.'/'.$path;
$path = $fileManagerFolder . '/' . $path;
} }


if (file_exists($path)) { if (file_exists($path)) {
} }
} }


return $this->cacheManager->getBrowserPath($this->getFileManagerFolder().'/'.$default, $thumb);
return $this->cacheManager->getBrowserPath($this->getFileManagerFolder() . '/' . $default, $thumb);
} }


public function getFileManagerFolder() public function getFileManagerFolder()

Loading…
Cancel
Save