<?php | |||||
namespace Lc\SovBundle\Controller\Newsletter; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||||
use Lc\SovBundle\Controller\AbstractAdminController; | |||||
use Lc\SovBundle\Field\BooleanField; | |||||
use Lc\SovBundle\Field\CKEditorField; | |||||
use Lc\SovBundle\Field\StatusField; | |||||
abstract class NewsletterAdminController extends AbstractAdminController | |||||
{ | |||||
public function configureFields(string $pageName): iterable | |||||
{ | |||||
$panel = parent::configureFields($pageName); | |||||
return array_merge( | |||||
[ | |||||
FormField::addPanel('general'), | |||||
TextField::new('title'), | |||||
BooleanField::new('isMain') | |||||
->setCustomOption('toggle_label', 'Principale'), | |||||
CKEditorField::new('description') | |||||
->hideOnIndex(), | |||||
StatusField::new('status'), | |||||
], | |||||
$panel | |||||
); | |||||
} | |||||
} |
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField; | use EasyCorp\Bundle\EasyAdminBundle\Field\FormField; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; | use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | ||||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | |||||
use Lc\SovBundle\Controller\AbstractAdminController; | use Lc\SovBundle\Controller\AbstractAdminController; | ||||
use Lc\SovBundle\Field\CKEditorField; | use Lc\SovBundle\Field\CKEditorField; | ||||
use Lc\SovBundle\Field\ImageManagerField; | |||||
use Lc\SovBundle\Field\StatusField; | use Lc\SovBundle\Field\StatusField; | ||||
abstract class PageAdminController extends AbstractAdminController | abstract class PageAdminController extends AbstractAdminController | ||||
{ | { | ||||
use AdminControllerTrait; | |||||
public function configureFields(string $pageName): iterable | public function configureFields(string $pageName): iterable | ||||
{ | { | ||||
$panel = parent::configureFields($pageName); | $panel = parent::configureFields($pageName); | ||||
[ | [ | ||||
FormField::addPanel('general'), | FormField::addPanel('general'), | ||||
TextField::new('title'), | TextField::new('title'), | ||||
ImageManagerField::new('image'), | |||||
NumberField::new('position') | NumberField::new('position') | ||||
->hideOnIndex() | ->hideOnIndex() | ||||
->hideOnForm(), | ->hideOnForm(), | ||||
StatusField::new('status'), | |||||
CKEditorField::new('description'), | CKEditorField::new('description'), | ||||
StatusField::new('status'), | |||||
], | ], | ||||
$panel | $panel | ||||
); | ); |
<?php | |||||
namespace Lc\SovBundle\Model\Newsletter ; | |||||
interface NewsletterInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Model\Newsletter; | |||||
use Doctrine\ORM\Mapping as ORM; | |||||
use Doctrine\Common\Collections\ArrayCollection; | |||||
use Doctrine\Common\Collections\Collection; | |||||
use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity; | |||||
use Lc\SovBundle\Model\User\UserInterface; | |||||
/** | |||||
* @ORM\MappedSuperclass() | |||||
*/ | |||||
abstract class NewsletterModel extends AbstractFullEntity implements NewsletterInterface | |||||
{ | |||||
/** | |||||
* @ORM\ManyToMany(targetEntity="Lc\SovBundle\Model\User\UserInterface", mappedBy="newsletters") | |||||
*/ | |||||
protected $users; | |||||
/** | |||||
* @ORM\Column(type="boolean", nullable=true) | |||||
*/ | |||||
protected $isMain; | |||||
public function __toString() | |||||
{ | |||||
return $this->getTitle(); | |||||
} | |||||
public function __construct() | |||||
{ | |||||
$this->users = new ArrayCollection(); | |||||
} | |||||
/** | |||||
* @return Collection|UserInterface[] | |||||
*/ | |||||
public function getUsers(): Collection | |||||
{ | |||||
return $this->users; | |||||
} | |||||
public function addUser(UserInterface $user): self | |||||
{ | |||||
if (!$this->users->contains($user)) { | |||||
$this->users[] = $user; | |||||
$user->addNewsletter($this); | |||||
} | |||||
return $this; | |||||
} | |||||
public function removeUser(UserInterface $user): self | |||||
{ | |||||
if ($this->users->contains($user)) { | |||||
$this->users->removeElement($user); | |||||
$user->removeNewsletter($this); | |||||
} | |||||
return $this; | |||||
} | |||||
public function getIsMain(): ?bool | |||||
{ | |||||
return $this->isMain; | |||||
} | |||||
public function setIsMain(?bool $isMain): self | |||||
{ | |||||
$this->isMain = $isMain; | |||||
return $this; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Repository\Newsletter; | |||||
use Lc\SovBundle\Model\Newsletter\NewsletterInterface; | |||||
use Lc\SovBundle\Repository\AbstractRepository; | |||||
/** | |||||
* @method NewsletterInterface|null find($id, $lockMode = null, $lockVersion = null) | |||||
* @method NewsletterInterface|null findOneBy(array $criteria, array $orderBy = null) | |||||
* @method NewsletterInterface[] findAll() | |||||
* @method NewsletterInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | |||||
*/ | |||||
class NewsletterRepository extends AbstractRepository | |||||
{ | |||||
public function getInterfaceClass() | |||||
{ | |||||
return NewsletterInterface::class; | |||||
} | |||||
} |
dashboard: Tableau de bord | dashboard: Tableau de bord | ||||
page: Pages | page: Pages | ||||
news: Actualités | news: Actualités | ||||
newsletters: Bulletins d'informations | |||||
user: Utilisateurs | user: Utilisateurs | ||||
user_index: Liste | user_index: Liste | ||||
account: Mon compte | account: Mon compte | ||||
News: | News: | ||||
label: Actualité | label: Actualité | ||||
label_plurial: Actualités | label_plurial: Actualités | ||||
Newsletter: | |||||
label: Bulletin d'information | |||||
label_plurial: Bulletins d'informations | |||||
fields: | |||||
isMain: Principale | |||||
Ticket: | Ticket: | ||||
fields: | fields: | ||||
visitorFirstName: Nom | visitorFirstName: Nom |