Browse Source

Merge branch 'develop' of https://forge.laclic.fr/Laclic/SovBundle into develop

feature/symfony6.1
Fabien Normand 3 years ago
parent
commit
abdb105449
15 changed files with 229 additions and 24 deletions
  1. +10
    -1
      Container/Newsletter/NewsletterContainer.php
  2. +10
    -1
      Container/Site/NewsContainer.php
  3. +10
    -1
      Container/Site/PageContainer.php
  4. +3
    -0
      Controller/AbstractAdminController.php
  5. +13
    -1
      Controller/ControllerTrait.php
  6. +21
    -8
      Definition/Field/AbstractFieldDefinition.php
  7. +45
    -0
      Definition/Field/Newsletter/NewsletterFieldDefinition.php
  8. +58
    -0
      Definition/Field/Site/NewsFieldDefinition.php
  9. +43
    -0
      Definition/Field/Site/PageFieldDefinition.php
  10. +0
    -3
      Model/Site/NewsModel.php
  11. +6
    -2
      Resources/translations/admin.fr.yaml
  12. +1
    -1
      Resources/views/admin/user/edit_password.html.twig
  13. +1
    -1
      Resources/views/admin/user/edit_profile.html.twig
  14. +1
    -1
      Resources/views/adminlte/crud/form.html.twig
  15. +7
    -4
      Resources/views/adminlte/layout.html.twig

+ 10
- 1
Container/Newsletter/NewsletterContainer.php View File

@@ -2,6 +2,7 @@

namespace Lc\SovBundle\Container\Newsletter;

use Lc\SovBundle\Definition\Field\Newsletter\NewsletterFieldDefinition;
use Lc\SovBundle\Factory\Newsletter\NewsletterFactory;
use Lc\SovBundle\Repository\Newsletter\NewsletterRepositoryQuery;
use Lc\SovBundle\Repository\Newsletter\NewsletterStore;
@@ -11,15 +12,18 @@ class NewsletterContainer
protected NewsletterFactory $factory;
protected NewsletterRepositoryQuery $repositoryQuery;
protected NewsletterStore $store;
protected NewsletterFieldDefinition $fieldDefinition;

public function __construct(
NewsletterFactory $factory,
NewsletterRepositoryQuery $repositoryQuery,
NewsletterStore $store
NewsletterStore $store,
NewsletterFieldDefinition $fieldDefinition
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
$this->fieldDefinition = $fieldDefinition;
}

public function getFactory(): NewsletterFactory
@@ -36,4 +40,9 @@ class NewsletterContainer
{
return $this->store;
}

public function getFieldDefinition(): NewsletterFieldDefinition
{
return $this->fieldDefinition;
}
}

+ 10
- 1
Container/Site/NewsContainer.php View File

@@ -2,6 +2,7 @@

namespace Lc\SovBundle\Container\Site;

use Lc\SovBundle\Definition\Field\Site\NewsFieldDefinition;
use Lc\SovBundle\Factory\Site\NewsFactory;
use Lc\SovBundle\Repository\Site\NewsRepositoryQuery;
use Lc\SovBundle\Repository\Site\NewsStore;
@@ -11,15 +12,18 @@ class NewsContainer
protected NewsFactory $factory;
protected NewsRepositoryQuery $repositoryQuery;
protected NewsStore $store;
protected NewsFieldDefinition $fieldDefinition;

public function __construct(
NewsFactory $factory,
NewsRepositoryQuery $repositoryQuery,
NewsStore $store
NewsStore $store,
NewsFieldDefinition $fieldDefinition
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
$this->fieldDefinition = $fieldDefinition;
}

public function getFactory(): NewsFactory
@@ -36,4 +40,9 @@ class NewsContainer
{
return $this->store;
}

public function getFieldDefinition(): NewsFieldDefinition
{
return $this->fieldDefinition;
}
}

+ 10
- 1
Container/Site/PageContainer.php View File

@@ -2,6 +2,7 @@

namespace Lc\SovBundle\Container\Site;

use Lc\SovBundle\Definition\Field\Site\PageFieldDefinition;
use Lc\SovBundle\Factory\Site\PageFactory;
use Lc\SovBundle\Repository\Site\PageRepositoryQuery;
use Lc\SovBundle\Repository\Site\PageStore;
@@ -11,15 +12,18 @@ class PageContainer
protected PageFactory $factory;
protected PageRepositoryQuery $repositoryQuery;
protected PageStore $store;
protected PageFieldDefinition $fieldDefinition;

public function __construct(
PageFactory $factory,
PageRepositoryQuery $repositoryQuery,
PageStore $store
PageStore $store,
PageFieldDefinition $fieldDefinition
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
$this->fieldDefinition = $fieldDefinition;
}

public function getFactory(): PageFactory
@@ -36,4 +40,9 @@ class PageContainer
{
return $this->store;
}

public function getFieldDefinition(): PageFieldDefinition
{
return $this->fieldDefinition;
}
}

+ 3
- 0
Controller/AbstractAdminController.php View File

@@ -154,6 +154,9 @@ abstract class AbstractAdminController extends EaAbstractCrudController
}else{
$crud->setDefaultSort(['id' => 'DESC']);
}
else {
$crud->setDefaultSort(['id' => 'DESC']);
}

return $crud;
}

+ 13
- 1
Controller/ControllerTrait.php View File

@@ -22,6 +22,7 @@ use Lc\SovBundle\Repository\EntityRepository;
use Lc\SovBundle\Solver\Setting\SettingSolver;
use Lc\SovBundle\Translation\FlashBagTranslator;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport;
use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@@ -54,6 +55,8 @@ trait ControllerTrait
TranslatorAdmin::class => TranslatorAdmin::class,
FilterManager::class => FilterManager::class,
FlashBagTranslator::class => FlashBagTranslator::class,
MailjetTransport::class => MailjetTransport::class,
AdminUrlGenerator::class => AdminUrlGenerator::class,
SettingSolver::class => SettingSolver::class,
ComponentContainer::class => ComponentContainer::class,
FileContainer::class => FileContainer::class,
@@ -72,7 +75,6 @@ trait ControllerTrait
);
}


public function addFlashTranslator(
string $type,
$translationKeyName,
@@ -181,6 +183,16 @@ trait ControllerTrait
return $this->get(LoggerInterface::class);
}

public function getMailjetTransport(): MailjetTransport
{
return $this->get(MailjetTransport::class);
}

public function getAdminUrlGenerator(): AdminUrlGenerator
{
return $this->get(AdminUrlGenerator::class);
}

public function getSettingSolver(): SettingSolver
{
return $this->get(SettingSolver::class);

+ 21
- 8
Definition/Field/AbstractFieldDefinition.php View File

@@ -8,9 +8,9 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\SovBundle\Field\CollectionField;
use Lc\SovBundle\Field\ImageManagerField;
use Lc\SovBundle\Field\StatusField;
use Lc\SovBundle\Translation\TranslatorAdmin;
use PhpParser\Node\Expr\Throw_;
use Symfony\Component\Form\Extension\Core\Type\TextType;

abstract class AbstractFieldDefinition
@@ -29,13 +29,17 @@ abstract class AbstractFieldDefinition
return [
'id' => IntegerField::new('id')->onlyOnIndex()->setSortable(true),
'metaTitle' => TextField::new('metaTitle')
->setLabel('Meta Title')
->setHelp('Affiché dans les résultats de recherche Google')
->hideOnIndex(),
->setLabel('Meta : title')
->setHelp('Affiché dans les résultats de recherche Google'),
'metaDescription' => TextareaField::new('metaDescription')
->setLabel('Meta description')
->setHelp('Affiché dans les résultats de recherche Google')
->hideOnIndex(),
->setLabel('Meta : description')
->setHelp('Affiché dans les résultats de recherche Google'),
'openGraphTitle' => TextField::new('openGraphTitle')
->setLabel('OpenGraph : titre'),
'openGraphDescription' => TextareaField::new('openGraphDescription')
->setLabel('OpenGraph : description'),
'openGraphImage' => ImageManagerField::new('openGraphImage')
->setLabel('OpenGraph : image'),
'oldUrls' => CollectionField::new('oldUrls')
->setFormTypeOption('entry_type', TextType::class)
->setLabel('Anciennes urls du document')
@@ -79,6 +83,15 @@ abstract class AbstractFieldDefinition
];
}

public function configurePanelOpengraph(): array
{
return [
'openGraphTitle',
'openGraphDescription',
'openGraphImage'
];
}

public function configurePanelConf(): array
{
return [
@@ -105,7 +118,7 @@ abstract class AbstractFieldDefinition
{
return array_merge(
$this->configureFieldsBase(),
$this->configureFields()
$this->configureFields(),
);
}


+ 45
- 0
Definition/Field/Newsletter/NewsletterFieldDefinition.php View File

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

namespace Lc\SovBundle\Definition\Field\Newsletter;

use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\SovBundle\Definition\Field\AbstractFieldDefinition;
use Lc\SovBundle\Field\BooleanField;
use Lc\SovBundle\Field\CKEditorField;

class NewsletterFieldDefinition extends AbstractFieldDefinition
{
public function configureIndex(): array
{
return [
'id',
'title',
'isMain',
'status'
];
}

public function configurePanels(): array
{
return ['main', 'seo', 'conf'];
}

public function configurePanelMain(): array
{
return [
'title',
'description',
'status'
];
}

public function configureFields(): array
{
return [
'title' => TextField::new('title'),
'description' => CKEditorField::new('description')->hideOnIndex(),
'isMain' => BooleanField::new('isMain')->setCustomOption('toggle_label', 'Principale'),
];
}

}

+ 58
- 0
Definition/Field/Site/NewsFieldDefinition.php View File

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

namespace Lc\SovBundle\Definition\Field\Site;

use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\DateField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\SovBundle\Definition\Field\AbstractFieldDefinition;
use Lc\SovBundle\Field\BooleanField;
use Lc\SovBundle\Field\ImageManagerField;

class NewsFieldDefinition extends AbstractFieldDefinition
{
public function configureIndex(): array
{
return [
'id',
'title',
'status'
];
}

public function configurePanels(): array
{
return ['main', 'seo', 'opengraph', 'conf'];
}

public function configurePanelMain(): array
{
return [
'date',
'title',
'newsletter',
'image',
'description',
'isSent',
'status'
];
}

public function configureFields(): array
{
return [
'date' => DateField::new('date')
->setFormat('d/MM/y')
->setSortable(true),
'title' => TextField::new('title')->setSortable(true),
'newsletter' => AssociationField::new('newsletter')->setSortable(true),
'image' => ImageManagerField::new('image'),
'position' => NumberField::new('position'),
'description' => TextEditorField::new('description'),
'isSent' => BooleanField::new('isSent')->setSortable(true),
];
}

}

+ 43
- 0
Definition/Field/Site/PageFieldDefinition.php View File

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

namespace Lc\SovBundle\Definition\Field\Site;

use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\SovBundle\Definition\Field\AbstractFieldDefinition;
use Lc\SovBundle\Field\CKEditorField;

class PageFieldDefinition extends AbstractFieldDefinition
{

public function configureIndex(): array
{
return [
'id',
'title',
'status'
];
}

public function configurePanelMain(): array
{
return [
'title',
'description',
'status'
];
}

public function configurePanels(): array
{
return ['main', 'seo', 'conf'];
}

public function configureFields(): array
{
return [
'title' => TextField::new('title')->setSortable(true),
'description' => CKEditorField::new('description')->hideOnIndex(),
];
}

}

+ 0
- 3
Model/Site/NewsModel.php View File

@@ -15,10 +15,8 @@ use Lc\SovBundle\Model\Newsletter\NewsletterInterface;
*/
abstract class NewsModel extends AbstractFullEntity implements NewsInterface, OpenGraphInterface
{

use OpenGraphTrait;


/**
* @ORM\Column(type="datetime")
* @Gedmo\Timestampable(on="create")
@@ -30,7 +28,6 @@ abstract class NewsModel extends AbstractFullEntity implements NewsInterface, Op
*/
protected $isSent;


/**
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\Newsletter\NewsletterInterface")
*/

+ 6
- 2
Resources/translations/admin.fr.yaml View File

@@ -118,10 +118,13 @@ entity:
status: Statut
email: Email
value: Valeur
metaTitle: Meta title
metaTitle: "Meta : titre"
metaTitle_help: Affiché dans les résultats de recherche Google
metaDescription: Meta description
metaDescription: "Meta : description"
metaDescription_help: Affiché dans les résultats de recherche Google
openGraphTitle: "Opengraph : titre"
openGraphDescription: "Opengraph : description"
openGraphImage: "Opengraph : image"
oldUrls: Anciennes urls
devAlias: Alias
gallery: Galerie
@@ -144,6 +147,7 @@ entity:
configuration: Configuration
gallery: Galerie
seo: Référencement
opengraph: Opengraph
flashes:
success:
created: L'élément a bien été créé

+ 1
- 1
Resources/views/admin/user/edit_password.html.twig View File

@@ -21,7 +21,7 @@
</div>

{% embed '@LcSov/adminlte/embed/form_footer.html.twig' %}
{% block width %}8{% endblock %}
{% block width %}12{% endblock %}
{% block content %}
{% import '@LcSov/adminlte/macro/button.html.twig' as mbutton %}
{{ mbutton.button({form: form_id, icon: 'fa fa-check'}) }}

+ 1
- 1
Resources/views/admin/user/edit_profile.html.twig View File

@@ -20,7 +20,7 @@
</div>

{% embed '@LcSov/adminlte/embed/form_footer.html.twig' %}
{% block width %}8{% endblock %}
{% block width %}12{% endblock %}
{% block content %}
{% import '@LcSov/adminlte/macro/button.html.twig' as mbutton %}
{{ mbutton.button({form: form_id, icon: 'fa fa-check'}) }}

+ 1
- 1
Resources/views/adminlte/crud/form.html.twig View File

@@ -92,7 +92,7 @@

{% block form_footer %}
{% embed '@LcSov/adminlte/embed/form_footer.html.twig' %}
{% block width %}8{% endblock %}
{% block width %}12{% endblock %}
{% block content %}
{% for action in entity.actions %}
{{ include(action.templatePath, { action: action }, with_context = false) }}&nbsp;

+ 7
- 4
Resources/views/adminlte/layout.html.twig View File

@@ -100,7 +100,6 @@
<div class="content-wrapper" style="min-height: 554px;">
{% block content %}
{% block content_header_wrapper %}

<section class="content-header">
<div class="container-fluid">
<div class="row mb-2">
@@ -153,11 +152,15 @@

<section class="content">
<div class="container-fluid">
{% block main %}{% endblock %}
{% if replace_content_with_message is defined %}
<div class="alert alert-warning" role="alert">
{{ replace_content_with_message }}
</div>
{% else %}
{% block main %}{% endblock %}
{% endif %}
</div>
</section>


{% endblock %}
</div>


Loading…
Cancel
Save