@@ -0,0 +1,33 @@ | |||
<?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 | |||
); | |||
} | |||
} |
@@ -5,17 +5,13 @@ namespace Lc\SovBundle\Controller\Site; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | |||
use Lc\SovBundle\Controller\AbstractAdminController; | |||
use Lc\SovBundle\Field\CKEditorField; | |||
use Lc\SovBundle\Field\ImageManagerField; | |||
use Lc\SovBundle\Field\StatusField; | |||
abstract class PageAdminController extends AbstractAdminController | |||
{ | |||
use AdminControllerTrait; | |||
public function configureFields(string $pageName): iterable | |||
{ | |||
$panel = parent::configureFields($pageName); | |||
@@ -24,12 +20,11 @@ abstract class PageAdminController extends AbstractAdminController | |||
[ | |||
FormField::addPanel('general'), | |||
TextField::new('title'), | |||
ImageManagerField::new('image'), | |||
NumberField::new('position') | |||
->hideOnIndex() | |||
->hideOnForm(), | |||
StatusField::new('status'), | |||
CKEditorField::new('description'), | |||
StatusField::new('status'), | |||
], | |||
$panel | |||
); |
@@ -0,0 +1,8 @@ | |||
<?php | |||
namespace Lc\SovBundle\Model\Newsletter ; | |||
interface NewsletterInterface | |||
{ | |||
} |
@@ -0,0 +1,76 @@ | |||
<?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; | |||
} | |||
} |
@@ -0,0 +1,20 @@ | |||
<?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; | |||
} | |||
} |
@@ -2,6 +2,7 @@ menu: | |||
dashboard: Tableau de bord | |||
page: Pages | |||
news: Actualités | |||
newsletters: Bulletins d'informations | |||
user: Utilisateurs | |||
user_index: Liste | |||
account: Mon compte | |||
@@ -55,6 +56,11 @@ entity: | |||
News: | |||
label: Actualité | |||
label_plurial: Actualités | |||
Newsletter: | |||
label: Bulletin d'information | |||
label_plurial: Bulletins d'informations | |||
fields: | |||
isMain: Principale | |||
Ticket: | |||
fields: | |||
visitorFirstName: Nom |