소스 검색

Crud Newsletter

ideas
Guillaume 3 년 전
부모
커밋
1d8a1bd510
6개의 변경된 파일144개의 추가작업 그리고 6개의 파일을 삭제
  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 파일 보기

@@ -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 파일 보기

@@ -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 파일 보기

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

namespace Lc\SovBundle\Model\Newsletter ;

interface NewsletterInterface
{

}

+ 76
- 0
Model/Newsletter/NewsletterModel.php 파일 보기

@@ -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 파일 보기

@@ -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 파일 보기

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

Loading…
취소
저장