浏览代码

FieldDefinitions

develop
Guillaume 3 年前
父节点
当前提交
542b253a29
共有 13 个文件被更改,包括 213 次插入23 次删除
  1. +10
    -1
      Container/Newsletter/NewsletterContainer.php
  2. +10
    -1
      Container/Site/NewsContainer.php
  3. +10
    -1
      Container/Site/PageContainer.php
  4. +21
    -8
      Definition/Field/AbstractFieldDefinition.php
  5. +45
    -0
      Definition/Field/Newsletter/NewsletterFieldDefinition.php
  6. +58
    -0
      Definition/Field/Site/NewsFieldDefinition.php
  7. +43
    -0
      Definition/Field/Site/PageFieldDefinition.php
  8. +0
    -3
      Model/Site/NewsModel.php
  9. +6
    -2
      Resources/translations/admin.fr.yaml
  10. +1
    -1
      Resources/views/admin/user/edit_password.html.twig
  11. +1
    -1
      Resources/views/admin/user/edit_profile.html.twig
  12. +1
    -1
      Resources/views/adminlte/crud/form.html.twig
  13. +7
    -4
      Resources/views/adminlte/layout.html.twig

+ 10
- 1
Container/Newsletter/NewsletterContainer.php 查看文件

@@ -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 查看文件

@@ -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 查看文件

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

+ 21
- 8
Definition/Field/AbstractFieldDefinition.php 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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 查看文件

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


正在加载...
取消
保存