Ver código fonte

Crud Newsletter

ideas
Guillaume 3 anos atrás
pai
commit
1d8a1bd510
6 arquivos alterados com 144 adições e 6 exclusões
  1. +33
    -0
      Controller/Newsletter/NewsletterAdminController.php
  2. +1
    -6
      Controller/Site/PageAdminController.php
  3. +8
    -0
      Model/Newsletter/NewsletterInterface.php
  4. +76
    -0
      Model/Newsletter/NewsletterModel.php
  5. +20
    -0
      Repository/Newsletter/NewsletterRepository.php
  6. +6
    -0
      Resources/translations/admin.fr.yaml

+ 33
- 0
Controller/Newsletter/NewsletterAdminController.php Ver arquivo

@@ -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
);
}

}

+ 1
- 6
Controller/Site/PageAdminController.php Ver arquivo

@@ -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
);

+ 8
- 0
Model/Newsletter/NewsletterInterface.php Ver arquivo

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

namespace Lc\SovBundle\Model\Newsletter ;

interface NewsletterInterface
{

}

+ 76
- 0
Model/Newsletter/NewsletterModel.php Ver arquivo

@@ -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;
}
}

+ 20
- 0
Repository/Newsletter/NewsletterRepository.php Ver arquivo

@@ -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;
}
}

+ 6
- 0
Resources/translations/admin.fr.yaml Ver arquivo

@@ -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

Carregando…
Cancelar
Salvar