Przeglądaj źródła

Crud Page & News

ideas
Guillaume 3 lat temu
rodzic
commit
a5916b7204
9 zmienionych plików z 252 dodań i 0 usunięć
  1. +38
    -0
      Controller/Site/NewsAdminController.php
  2. +39
    -0
      Controller/Site/PageAdminController.php
  3. +8
    -0
      Model/Site/NewsInterface.php
  4. +37
    -0
      Model/Site/NewsModel.php
  5. +8
    -0
      Model/Site/PageInterface.php
  6. +75
    -0
      Model/Site/PageModel.php
  7. +20
    -0
      Repository/Site/NewsRepository.php
  8. +20
    -0
      Repository/Site/PageRepository.php
  9. +7
    -0
      Resources/translations/admin.fr.yaml

+ 38
- 0
Controller/Site/NewsAdminController.php Wyświetl plik

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

namespace Lc\SovBundle\Controller\Site;

use EasyCorp\Bundle\EasyAdminBundle\Field\DateField;
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Field\CKEditorField;
use Lc\SovBundle\Field\ImageManagerField;
use Lc\SovBundle\Field\StatusField;

abstract class NewsAdminController extends AbstractAdminController
{

public function configureFields(string $pageName): iterable
{
$panel = parent::configureFields($pageName);

return array_merge(
[
FormField::addPanel('general'),
TextField::new('title'),
DateField::new('date')
->setFormat('d/MM/y'),
NumberField::new('position')
->hideOnIndex()
->hideOnForm(),
CKEditorField::new('description'),
StatusField::new('status'),
],
$panel
);
}


}

+ 39
- 0
Controller/Site/PageAdminController.php Wyświetl plik

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

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

return array_merge(
[
FormField::addPanel('general'),
TextField::new('title'),
ImageManagerField::new('image'),
NumberField::new('position')
->hideOnIndex()
->hideOnForm(),
StatusField::new('status'),
CKEditorField::new('description'),
],
$panel
);
}


}

+ 8
- 0
Model/Site/NewsInterface.php Wyświetl plik

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

namespace Lc\SovBundle\Model\Site ;

interface NewsInterface
{

}

+ 37
- 0
Model/Site/NewsModel.php Wyświetl plik

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

namespace Lc\SovBundle\Model\Site;

use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity;

/**
* @ORM\MappedSuperclass()
*/
abstract class NewsModel extends AbstractFullEntity implements NewsInterface
{

/**
* @ORM\Column(type="datetime")
* @Gedmo\Timestampable(on="create")
*/
protected $date;

public function __toString()
{
return $this->getTitle();
}

public function getDate(): ?\DateTimeInterface
{
return $this->date;
}

public function setDate(\DateTimeInterface $date): self
{
$this->date = $date;

return $this;
}
}

+ 8
- 0
Model/Site/PageInterface.php Wyświetl plik

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

namespace Lc\SovBundle\Model\Site;

interface PageInterface
{

}

+ 75
- 0
Model/Site/PageModel.php Wyświetl plik

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

namespace Lc\SovBundle\Model\Site;

use Doctrine\ORM\Mapping as ORM;
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface;
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity;

/**
* @ORM\MappedSuperclass()
*/
abstract class PageModel extends AbstractFullEntity implements PageInterface
{
/**
* @ORM\Column(type="text", nullable=true)
*/
protected $content;

/**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface", inversedBy="pages")
* @ORM\JoinColumn(nullable=false)
*/
protected $merchant;

/**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface", inversedBy="pages")
*/
protected $section;


public function __toString()
{
return $this->getTitle();
}

public function getContent(): ?string
{
return $this->content;
}

public function setContent(?string $content): self
{
$this->content = $content;

return $this;
}

public function getMerchant(): ?MerchantInterface
{
return $this->merchant;
}

public function setMerchant(?MerchantInterface $merchant): self
{
$this->merchant = $merchant;

return $this;
}

public function getSection(): ?SectionInterface
{
return $this->section;
}

public function setSection(?SectionInterface $section): self
{
$this->section = $section;

return $this;
}

}

+ 20
- 0
Repository/Site/NewsRepository.php Wyświetl plik

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

namespace Lc\SovBundle\Repository\Site;

use Lc\SovBundle\Model\Site\NewsInterface;
use Lc\SovBundle\Repository\AbstractRepository;

/**
* @method NewsInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method NewsInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method NewsInterface[] findAll()
* @method NewsInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class NewsRepository extends AbstractRepository
{
public function getInterfaceClass()
{
return NewsInterface::class;
}
}

+ 20
- 0
Repository/Site/PageRepository.php Wyświetl plik

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

namespace Lc\SovBundle\Repository\Site;

use Lc\SovBundle\Model\Site\PageInterface;
use Lc\SovBundle\Repository\AbstractRepository;

/**
* @method PageInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method PageInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method PageInterface[] findAll()
* @method PageInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class PageRepository extends AbstractRepository
{
public function getInterfaceClass()
{
return PageInterface::class;
}
}

+ 7
- 0
Resources/translations/admin.fr.yaml Wyświetl plik

@@ -1,6 +1,7 @@
menu:
dashboard: Tableau de bord
page: Pages
news: Actualités
user: Utilisateurs
user_index: Liste
account: Mon compte
@@ -16,6 +17,7 @@ title:
new: Ajouter "%label%"
edit: Modifier "%label%" (#%id%)
detail: Voir "%label%" (#%id%)
un_titre: Un titre
account:
profile: Mes informations personnelles
change_password: Changer de mot de passe
@@ -50,6 +52,9 @@ entity:
Page:
label: Page
label_plurial: Pages
News:
label: Actualité
label_plurial: Actualités
Ticket:
fields:
visitorFirstName: Nom
@@ -85,6 +90,8 @@ entity:
gallery: Galerie
color: Couleur
active: Activer
image: Image
date: Date

panels:
general: Général

Ładowanie…
Anuluj
Zapisz