Quellcode durchsuchen

Refactoring frontend

develop
Guillaume vor 3 Jahren
Ursprung
Commit
6dfacd908f
5 geänderte Dateien mit 91 neuen und 5 gelöschten Zeilen
  1. +1
    -1
      Model/File/FileModel.php
  2. +5
    -0
      Repository/AbstractRepositoryQuery.php
  3. +13
    -3
      Repository/AbstractStore.php
  4. +58
    -0
      Twig/MetaTwigExtension.php
  5. +14
    -1
      Twig/TwigExtension.php

+ 1
- 1
Model/File/FileModel.php Datei anzeigen

@@ -39,7 +39,7 @@ abstract class FileModel implements SortableInterface, BlameableInterface, Times


public function __toString(){
return $this->getLegend();
return ''.$this->getLegend();
}

public function getPath(): ?string

+ 5
- 0
Repository/AbstractRepositoryQuery.php Datei anzeigen

@@ -133,6 +133,11 @@ abstract class AbstractRepositoryQuery implements RepositoryQueryInterface
return $this->andWhere('.'.$field.' = :'.$field)->setParameter($field, $value);
}

public function filterByOldUrl(string $oldUrl): self
{
return $this->andWhere(':oldUrl IN .oldUrls')->setParameter('oldUrl', $oldUrl);
}

/*
* DEVALIAS
*/

+ 13
- 3
Repository/AbstractStore.php Datei anzeigen

@@ -57,7 +57,7 @@ abstract class AbstractStore implements StoreInterface

public function getOneBySlug(string $slug, bool $isOnline = true, $query = null)
{
$query = $this->createDefaultQuery($query);
$query = $this->createQuery($query);
$query->filterBySlug($slug);

if ($isOnline) {
@@ -69,14 +69,14 @@ abstract class AbstractStore implements StoreInterface

public function getOneByDevAlias(string $devAlias, $query = null)
{
$query = $this->createDefaultQuery($query);
$query = $this->createQuery($query);
$query->filterByDevAlias($devAlias);
return $query->findOne();
}

public function getOneOnlineByDevAlias(string $devAlias, $query = null)
{
$query = $this->createDefaultQuery($query);
$query = $this->createQuery($query);
$query
->filterByDevAlias($devAlias)
->filterIsOnline();
@@ -84,6 +84,16 @@ abstract class AbstractStore implements StoreInterface
return $query->findOne();
}

public function getOneByOldUrl(string $oldUrl, $query = null)
{
$query = $this->createQuery($query);
$query
->filterByOldUrl($oldUrl)
->filterIsOnline();

return $query->findOne();
}

public function get($query = null)
{
$query = $this->createDefaultQuery($query);

+ 58
- 0
Twig/MetaTwigExtension.php Datei anzeigen

@@ -0,0 +1,58 @@
<?php

namespace Lc\SovBundle\Twig;

use Lc\SovBundle\Component\MetaComponent;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

class MetaTwigExtension extends AbstractExtension
{
protected MetaComponent $metaComponent;

public function __construct(MetaComponent $metaComponent)
{
$this->metaComponent = $metaComponent;
}

public function getFunctions()
{
return [
new TwigFunction('sov_meta_title', [$this, 'getMetaTitle']),
new TwigFunction('sov_meta_description', [$this, 'getMetaDescription']),
new TwigFunction('sov_opengraph_title', [$this, 'getOpengraphTitle']),
new TwigFunction('sov_opengraph_description', [$this, 'getOpengraphDescription']),
new TwigFunction('sov_opengraph_image', [$this, 'getOpengraphImage']),
];
}

public function getFilters()
{
return [];
}

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

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

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

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

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

+ 14
- 1
Twig/TwigExtension.php Datei anzeigen

@@ -4,6 +4,8 @@ namespace Lc\SovBundle\Twig;

use App\Repository\ReminderRepository;
use Doctrine\ORM\EntityManagerInterface;
use Lc\SovBundle\Component\MetaComponent;
use Lc\SovBundle\Component\StringComponent;
use Lc\SovBundle\Form\Newsletter\NewsletterType;
use Lc\SovBundle\Repository\Reminder\ReminderStore;
use Lc\SovBundle\Translation\TranslatorAdmin;
@@ -32,6 +34,7 @@ class TwigExtension extends AbstractExtension
protected $reminderStore;
protected $security;
protected FormFactoryInterface $formFactory;
protected StringComponent $stringComponent;

public function __construct(
KernelInterface $kernel,
@@ -44,7 +47,9 @@ class TwigExtension extends AbstractExtension
TranslatorAdmin $translatorAdmin,
ReminderStore $reminderStore,
Security $security,
FormFactoryInterface $formFactory
FormFactoryInterface $formFactory,
StringComponent $stringComponent,
MetaComponent $metaComponent
) {
$this->kernel = $kernel;
$this->parameterBag = $parameterBag;
@@ -57,6 +62,8 @@ class TwigExtension extends AbstractExtension
$this->reminderStore = $reminderStore;
$this->security = $security;
$this->formFactory = $formFactory;
$this->stringComponent = $stringComponent;
$this->metaComponent = $metaComponent;
}

public function getFunctions()
@@ -69,6 +76,7 @@ class TwigExtension extends AbstractExtension
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']),
];
}

@@ -152,4 +160,9 @@ class TwigExtension extends AbstractExtension
return $form->createView();
}

public function limitText(string $text, int $limit)
{
return $this->stringComponent->limitText($text, $limit);
}

}

Laden…
Abbrechen
Speichern