Browse Source

Refactoring modèles

tags/0.1
Guillaume 3 years ago
parent
commit
0036ba9328
15 changed files with 164 additions and 171 deletions
  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 View File



namespace Lc\SovBundle\Controller\Admin; namespace Lc\SovBundle\Controller\Admin;


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

+ 0
- 2
Controller/Admin/DashboardController.php View File



namespace Lc\SovBundle\Controller\Admin; namespace Lc\SovBundle\Controller\Admin;


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

+ 2
- 2
Doctrine/Extension/BlameableTrait.php View File



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


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

+ 1
- 1
Doctrine/Extension/OpenGraphTrait.php View File

protected $openGraphDescription; protected $openGraphDescription;


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



+ 40
- 40
Doctrine/Extension/SeoTrait.php View File



trait SeoTrait 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 View File



trait SluggableTrait 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 View File



trait SortableTrait 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 View File



trait StatusTrait 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 View File



trait TimestampableTrait 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 View File



trait TranslatableTrait 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 View File

/** /**
* @ORM\MappedSuperclass * @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; use BlameableTrait;

Doctrine/Pattern/EntityLightAbstract.php → Doctrine/Pattern/AbstractLightEntity.php View File

/** /**
* @ORM\MappedSuperclass * @ORM\MappedSuperclass
*/ */
abstract class EntityLightAbstract implements BlameableInterface, TimestampableInterface, DevAliasInterface,
abstract class AbstractLightEntity implements BlameableInterface, TimestampableInterface, DevAliasInterface,
EntityInterface EntityInterface
{ {



Repository/RepositoryAbstract.php → Repository/AbstractRepository.php View File

use Gedmo\Translatable\TranslatableListener; use Gedmo\Translatable\TranslatableListener;
use Lc\SovBundle\Doctrine\Extension\StatusInterface; use Lc\SovBundle\Doctrine\Extension\StatusInterface;


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


protected $defaultLocale; protected $defaultLocale;

Repository/RepositoryAbstractInterface.php → Repository/AbstractRepositoryInterface.php View File

namespace Lc\SovBundle\Repository; namespace Lc\SovBundle\Repository;




interface RepositoryAbstractInterface
interface AbstractRepositoryInterface
{ {


/** /**

+ 0
- 3
Twig/TwigExtension.php View File



namespace Lc\SovBundle\Twig; namespace Lc\SovBundle\Twig;



use App\Entity\Page;

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

Loading…
Cancel
Save