Charly преди 3 години
родител
ревизия
c27c8c912a
променени са 15 файла, в които са добавени 419 реда и са изтрити 16 реда
  1. +3
    -9
      Controller/AbstractAdminController.php
  2. +33
    -0
      Controller/Newsletter/NewsletterAdminController.php
  3. +38
    -0
      Controller/Site/NewsAdminController.php
  4. +34
    -0
      Controller/Site/PageAdminController.php
  5. +8
    -0
      Model/Newsletter/NewsletterInterface.php
  6. +76
    -0
      Model/Newsletter/NewsletterModel.php
  7. +8
    -0
      Model/Site/NewsInterface.php
  8. +37
    -0
      Model/Site/NewsModel.php
  9. +8
    -0
      Model/Site/PageInterface.php
  10. +75
    -0
      Model/Site/PageModel.php
  11. +20
    -0
      Repository/Newsletter/NewsletterRepository.php
  12. +20
    -0
      Repository/Site/NewsRepository.php
  13. +20
    -0
      Repository/Site/PageRepository.php
  14. +13
    -0
      Resources/translations/admin.fr.yaml
  15. +26
    -7
      Resources/views/adminlte/crud/form_theme.html.twig

+ 3
- 9
Controller/AbstractAdminController.php Целия файл

@@ -8,10 +8,8 @@ use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection;
use EasyCorp\Bundle\EasyAdminBundle\Collection\FilterCollection;
use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
use EasyCorp\Bundle\EasyAdminBundle\Config\Assets;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore;
use EasyCorp\Bundle\EasyAdminBundle\Config\Option\EA;
use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController as EaAbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto;
@@ -20,7 +18,6 @@ use EasyCorp\Bundle\EasyAdminBundle\Event\AfterCrudActionEvent;
use EasyCorp\Bundle\EasyAdminBundle\Event\AfterEntityUpdatedEvent;
use EasyCorp\Bundle\EasyAdminBundle\Event\BeforeCrudActionEvent;
use EasyCorp\Bundle\EasyAdminBundle\Event\BeforeEntityDeletedEvent;
use EasyCorp\Bundle\EasyAdminBundle\Event\BeforeEntityUpdatedEvent;
use EasyCorp\Bundle\EasyAdminBundle\Exception\ForbiddenActionException;
use EasyCorp\Bundle\EasyAdminBundle\Exception\InsufficientEntityPermissionException;
use EasyCorp\Bundle\EasyAdminBundle\Factory\EntityFactory;
@@ -30,18 +27,14 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator;
use EasyCorp\Bundle\EasyAdminBundle\Security\Permission;
use Lc\SovBundle\Doctrine\EntityManager;
use Lc\SovBundle\Doctrine\Extension\DevAliasInterface;
use Lc\SovBundle\Doctrine\Extension\SeoInterface;
use Lc\SovBundle\Doctrine\Extension\SortableInterface;
use Lc\SovBundle\Doctrine\Extension\TranslatableInterface;
use Lc\SovBundle\Doctrine\Extension\TreeInterface;
use Lc\SovBundle\Field\CollectionField;
use Lc\SovBundle\Field\GalleryManagerField;
use Lc\SovBundle\Form\Type\Crud\PositionType;
use Lc\SovBundle\Form\Common\PositionType;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\HttpFoundation\RequestStack;
@@ -308,7 +301,8 @@ abstract class AbstractAdminController extends EaAbstractCrudController
return $event->getResponse();
}

if (!$this->isGranted(Permission::EA_EXECUTE_ACTION) || !$this->isInstanceOf(SortableInterface::class)) {
//if (!$this->isGranted(Permission::EA_EXECUTE_ACTION) || !$this->isInstanceOf(SortableInterface::class)) {
if (!$this->isInstanceOf(SortableInterface::class)) {
throw new ForbiddenActionException($context);
}


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

}

+ 38
- 0
Controller/Site/NewsAdminController.php Целия файл

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


}

+ 34
- 0
Controller/Site/PageAdminController.php Целия файл

@@ -0,0 +1,34 @@
<?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\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Field\CKEditorField;
use Lc\SovBundle\Field\StatusField;

abstract class PageAdminController extends AbstractAdminController
{

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

return array_merge(
[
FormField::addPanel('general'),
TextField::new('title'),
NumberField::new('position')
->hideOnIndex()
->hideOnForm(),
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;
}
}

+ 8
- 0
Model/Site/NewsInterface.php Целия файл

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

namespace Lc\SovBundle\Model\Site ;

interface NewsInterface
{

}

+ 37
- 0
Model/Site/NewsModel.php Целия файл

@@ -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 Целия файл

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

namespace Lc\SovBundle\Model\Site;

interface PageInterface
{

}

+ 75
- 0
Model/Site/PageModel.php Целия файл

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

+ 20
- 0
Repository/Site/NewsRepository.php Целия файл

@@ -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 Целия файл

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

+ 13
- 0
Resources/translations/admin.fr.yaml Целия файл

@@ -1,6 +1,8 @@
menu:
dashboard: Tableau de bord
page: Pages
news: Actualités
newsletters: Bulletins d'informations
user: Utilisateurs
user_index: Liste
account: Mon compte
@@ -16,6 +18,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
@@ -51,6 +54,14 @@ entity:
Page:
label: Page
label_plurial: Pages
News:
label: Actualité
label_plurial: Actualités
Newsletter:
label: Bulletin d'information
label_plurial: Bulletins d'informations
fields:
isMain: Principale
Ticket:
label: Ticket
label_plurial: Tickets
@@ -93,6 +104,8 @@ entity:
gallery: Galerie
color: Couleur
active: Activer
image: Image
date: Date

panels:
general: Général

+ 26
- 7
Resources/views/adminlte/crud/form_theme.html.twig Целия файл

@@ -9,15 +9,30 @@
<div {% with { attr: row_attr } %}{{ block('attributes') }}{% endwith %}>
{{- form_label(form) -}}
<div class="form-widget">
{% set has_prepend_html = ea.field.prepend_html|default(null) is not null %}
{% set has_append_html = ea.field.append_html|default(null) is not null %}
{% set has_input_groups = has_prepend_html or has_append_html %}

{#
{% set has_prepend_html = ea.field.prepend_html|default(null) is not null %}
{% set has_append_html = ea.field.append_html|default(null) is not null %}
{% set has_input_groups = has_prepend_html or has_append_html %}
#}

{% set has_prepend_html = false %}
{% set has_append_html = false %}
{% set has_input_groups = false %}

{% if ea_crud_form.ea_field is defined and ea_crud_form.ea_field is not null %}
{% set prepend_html = ea_crud_form.ea_field.customOptions.get('prependHtml') %}
{% set append_html = ea_crud_form.ea_field.customOptions.get('appendHtml') %}
{% set has_prepend_html = prepend_html is not null %}
{% set has_append_html = append_html is not null %}
{% set has_input_groups = has_prepend_html or has_append_html %}
{% endif %}

{% if has_input_groups %}
<div class="input-group">{% endif %}
{% if has_prepend_html %}
<div class="input-group-prepend">
<span class="input-group-text">{{ ea.field.prepend_html|raw }}</span>
<span class="input-group-text">{{ prepend_html|raw }}</span>
</div>
{% endif %}

@@ -25,7 +40,7 @@

{% if has_append_html %}
<div class="input-group-append">
<span class="input-group-text">{{ ea.field.append_html|raw }}</span>
<span class="input-group-text">{{ append_html|raw }}</span>
</div>
{% endif %}
{% if has_input_groups %}</div>{% endif %}
@@ -78,8 +93,12 @@
{%- endif -%}
{%- endif -%}

{# <{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}>{{ (translation_domain is same as(false)) ? label : label|lower|lc_trans_admin_field(ea.getEntity().getFqcn()) }}</{{ element|default('label') }}> #}
<{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}>{{ (label is not empty and '.' in label) ? label|trans({}, 'admin') : name|lc_trans_admin_field(form.parent.vars.data) }}</{{ element|default('label') }}>
{% set entityNameOrObject = form.parent.vars.data %}
{% if not entityNameOrObject and form.parent.vars.errors.form.config.dataClass is defined %}
{% set entityNameOrObject = form.parent.vars.errors.form.config.dataClass %}
{% endif %}

<{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}>{{ (label is not empty and '.' in label) ? label|trans({}, 'admin') : name|lc_trans_admin_field(entityNameOrObject) }}</{{ element|default('label') }}>

{%- endif -%}
{%- endblock form_label %}

Loading…
Отказ
Запис