Parcourir la source

Refactoring modèles

tags/0.1
Guillaume il y a 3 ans
Parent
révision
0036ba9328
15 fichiers modifiés avec 164 ajouts et 171 suppressions
  1. +0
    -1
      Controller/Admin/AbstractCrudController.php
  2. +0
    -2
      Controller/Admin/DashboardController.php
  3. +2
    -2
      Doctrine/Extension/BlameableTrait.php
  4. +1
    -1
      Doctrine/Extension/OpenGraphTrait.php
  5. +40
    -40
      Doctrine/Extension/SeoTrait.php
  6. +14
    -14
      Doctrine/Extension/SluggableTrait.php
  7. +21
    -21
      Doctrine/Extension/SortableTrait.php
  8. +13
    -13
      Doctrine/Extension/StatusTrait.php
  9. +35
    -35
      Doctrine/Extension/TimestampableTrait.php
  10. +32
    -33
      Doctrine/Extension/TranslatableTrait.php
  11. +2
    -2
      Doctrine/Pattern/AbstractFullEntity.php
  12. +1
    -1
      Doctrine/Pattern/AbstractLightEntity.php
  13. +2
    -2
      Repository/AbstractRepository.php
  14. +1
    -1
      Repository/AbstractRepositoryInterface.php
  15. +0
    -3
      Twig/TwigExtension.php

+ 0
- 1
Controller/Admin/AbstractCrudController.php Voir le fichier

@@ -2,7 +2,6 @@

namespace Lc\SovBundle\Controller\Admin;

use App\Entity\Page;
use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
use EasyCorp\Bundle\EasyAdminBundle\Config\Assets;

+ 0
- 2
Controller/Admin/DashboardController.php Voir le fichier

@@ -2,8 +2,6 @@

namespace Lc\SovBundle\Controller\Admin;

use App\Entity\Page;
use App\Entity\User;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard;
use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;

+ 2
- 2
Doctrine/Extension/BlameableTrait.php Voir le fichier

@@ -11,14 +11,14 @@ trait BlameableTrait

/**
* @Gedmo\Blameable(on="create")
* @ORM\ManyToOne(targetEntity="App\Entity\User")
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface")
* @ORM\JoinColumn(nullable=false)
*/
protected $createdBy;

/**
* @Gedmo\Blameable(on="update")
* @ORM\ManyToOne(targetEntity="App\Entity\User")
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface")
* @ORM\JoinColumn(nullable=false)
*/
protected $updatedBy;

+ 1
- 1
Doctrine/Extension/OpenGraphTrait.php Voir le fichier

@@ -19,7 +19,7 @@ trait OpenGraphTrait
protected $openGraphDescription;

/**
* @ORM\ManyToOne(targetEntity=FileInterface::class, cascade={"persist", "remove"})
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\File\FileInterface", cascade={"persist", "remove"})
*/
protected $openGraphImage;


+ 40
- 40
Doctrine/Extension/SeoTrait.php Voir le fichier

@@ -6,58 +6,58 @@ use Doctrine\ORM\Mapping as ORM;

trait SeoTrait
{
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $metaTitle;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $metaTitle;


/**
* @ORM\Column(type="text", nullable=true)
*/
protected $metaDescription;
/**
* @ORM\Column(type="text", nullable=true)
*/
protected $metaDescription;


/**
* @var array
* @ORM\Column(type="array", nullable=true)
*/
protected $oldUrls;
/**
* @var array
* @ORM\Column(type="array", nullable=true)
*/
protected $oldUrls;


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

public function setMetaTitle(?string $metaTitle): self
{
$this->metaTitle = $metaTitle;
public function setMetaTitle(?string $metaTitle): self
{
$this->metaTitle = $metaTitle;

return $this;
}
return $this;
}

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

public function setMetaDescription(?string $metaDescription): self
{
$this->metaDescription = $metaDescription;
public function setMetaDescription(?string $metaDescription): self
{
$this->metaDescription = $metaDescription;

return $this;
}
return $this;
}

public function setOldUrls($oldUrls): self
{
$this->oldUrls = $oldUrls;
public function setOldUrls($oldUrls): self
{
$this->oldUrls = $oldUrls;

return $this;
}
return $this;
}

public function getOldUrls(): ?array
{
return $this->oldUrls;
}
public function getOldUrls(): ?array
{
return $this->oldUrls;
}
}

+ 14
- 14
Doctrine/Extension/SluggableTrait.php Voir le fichier

@@ -7,21 +7,21 @@ use Gedmo\Mapping\Annotation as Gedmo;

trait SluggableTrait
{
/**
* @ORM\Column(type="string", length=255)
* @Gedmo\Slug(fields={"title"})
*/
protected $slug;
/**
* @ORM\Column(type="string", length=255)
* @Gedmo\Slug(fields={"title"})
*/
protected $slug;

public function getSlug(): ?string
{
return $this->slug;
}
public function getSlug(): ?string
{
return $this->slug;
}

public function setSlug(?string $slug): self
{
$this->slug = $slug;
public function setSlug(?string $slug): self
{
$this->slug = $slug;

return $this;
}
return $this;
}
}

+ 21
- 21
Doctrine/Extension/SortableTrait.php Voir le fichier

@@ -8,27 +8,27 @@ use Gedmo\Mapping\Annotation as Gedmo;

trait SortableTrait
{
/**
* @var string
* @ORM\Column(type="float")
*/
protected $position = 0;
/**
* @var string
* @ORM\Column(type="float")
*/
protected $position = 0;

/**
* @return float
*/
public function getPosition(): float
{
return $this->position;
}
/**
* @return float
*/
public function getPosition(): float
{
return $this->position;
}

/**
* @param float $position
* @return $this
*/
public function setPosition(float $position): self
{
$this->position = $position;
return $this;
}
/**
* @param float $position
* @return $this
*/
public function setPosition(float $position): self
{
$this->position = $position;
return $this;
}
}

+ 13
- 13
Doctrine/Extension/StatusTrait.php Voir le fichier

@@ -6,20 +6,20 @@ use Doctrine\ORM\Mapping as ORM;

trait StatusTrait
{
/**
* @ORM\Column(type="float")
*/
protected $status;
/**
* @ORM\Column(type="float")
*/
protected $status;

public function getStatus(): ?float
{
return $this->status;
}
public function getStatus(): ?float
{
return $this->status;
}

public function setStatus(float $status): self
{
$this->status = $status;
public function setStatus(float $status): self
{
$this->status = $status;

return $this;
}
return $this;
}
}

+ 35
- 35
Doctrine/Extension/TimestampableTrait.php Voir le fichier

@@ -7,40 +7,40 @@ use Gedmo\Mapping\Annotation as Gedmo;

trait TimestampableTrait
{
/**
* @ORM\Column(type="datetime")
* @Gedmo\Timestampable(on="create")
*/
protected $createdAt;
/**
* @ORM\Column(type="datetime")
* @Gedmo\Timestampable(on="update")
*/
protected $updatedAt;
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* @ORM\Column(type="datetime")
* @Gedmo\Timestampable(on="create")
*/
protected $createdAt;
/**
* @ORM\Column(type="datetime")
* @Gedmo\Timestampable(on="update")
*/
protected $updatedAt;
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}

}

+ 32
- 33
Doctrine/Extension/TranslatableTrait.php Voir le fichier

@@ -7,42 +7,41 @@ use Gedmo\Mapping\Annotation as Gedmo;

trait TranslatableTrait
{
/**
* Post locale
* Used locale to override Translation listener's locale
* @Gedmo\Locale
*/
protected $locale;

/**
* @ORM\Column(type="array", nullable=true)
*/
protected $localesEnabled = [];

public function __get($name)
{
if(isset($this->{$name})) {
return $this->{$name};
}else{
return null;
}

/**
* Post locale
* Used locale to override Translation listener's locale
* @Gedmo\Locale
*/
protected $locale;

/**
* @ORM\Column(type="array", nullable=true)
*/
protected $localesEnabled = [];

public function __get($name)
{
if (isset($this->{$name})) {
return $this->{$name};
} else {
return null;
}
}

public function setTranslatableLocale($locale)
{
$this->locale = $locale;
}
public function setTranslatableLocale($locale)
{
$this->locale = $locale;
}

public function getLocalesEnabled(): ?array
{
return $this->localesEnabled;
}
public function getLocalesEnabled(): ?array
{
return $this->localesEnabled;
}

public function setLocalesEnabled(?array $localesEnabled): self
{
$this->localesEnabled = $localesEnabled;
public function setLocalesEnabled(?array $localesEnabled): self
{
$this->localesEnabled = $localesEnabled;

return $this;
}
return $this;
}
}

Doctrine/Pattern/EntityFullAbstract.php → Doctrine/Pattern/AbstractFullEntity.php Voir le fichier

@@ -24,8 +24,8 @@ use Lc\SovBundle\Doctrine\Extension\TimestampableTrait;
/**
* @ORM\MappedSuperclass
*/
abstract class EntityFullAbstract implements BlameableInterface, SeoInterface, SluggableInterface, SortableInterface,
StatusInterface, TimestampableInterface, DevAliasInterface, EntityInterface
abstract class AbstractFullEntity implements BlameableInterface, SeoInterface, SluggableInterface, SortableInterface,
StatusInterface, TimestampableInterface, DevAliasInterface, EntityInterface
{

use BlameableTrait;

Doctrine/Pattern/EntityLightAbstract.php → Doctrine/Pattern/AbstractLightEntity.php Voir le fichier

@@ -16,7 +16,7 @@ use Lc\SovBundle\Doctrine\Extension\TimestampableTrait;
/**
* @ORM\MappedSuperclass
*/
abstract class EntityLightAbstract implements BlameableInterface, TimestampableInterface, DevAliasInterface,
abstract class AbstractLightEntity implements BlameableInterface, TimestampableInterface, DevAliasInterface,
EntityInterface
{


Repository/RepositoryAbstract.php → Repository/AbstractRepository.php Voir le fichier

@@ -11,8 +11,8 @@ use Doctrine\ORM\QueryBuilder;
use Gedmo\Translatable\TranslatableListener;
use Lc\SovBundle\Doctrine\Extension\StatusInterface;

abstract class RepositoryAbstract extends EntityRepository implements ServiceEntityRepositoryInterface,
RepositoryAbstractInterface
abstract class AbstractRepository extends EntityRepository implements ServiceEntityRepositoryInterface,
AbstractRepositoryInterface
{

protected $defaultLocale;

Repository/RepositoryAbstractInterface.php → Repository/AbstractRepositoryInterface.php Voir le fichier

@@ -3,7 +3,7 @@
namespace Lc\SovBundle\Repository;


interface RepositoryAbstractInterface
interface AbstractRepositoryInterface
{

/**

+ 0
- 3
Twig/TwigExtension.php Voir le fichier

@@ -2,9 +2,6 @@

namespace Lc\SovBundle\Twig;


use App\Entity\Page;

use Doctrine\ORM\EntityManagerInterface;
use Liip\ImagineBundle\Imagine\Cache\CacheManager;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;

Chargement…
Annuler
Enregistrer