diff --git a/composer.json b/composer.json index 8931f39..e0d8c94 100644 --- a/composer.json +++ b/composer.json @@ -6,6 +6,7 @@ "license": "MIT", "require": { "monsieurbiz/sylius-plus-adapter-plugin": "^1.1", + "monsieurbiz/sylius-media-manager-plugin": "^1.1", "monsieurbiz/sylius-rich-editor-plugin": "^2.8", "php": "^8.0", "sylius/sylius": ">=1.11 <1.14" diff --git a/src/Entity/Page.php b/src/Entity/Page.php index 2bde616..abd9728 100644 --- a/src/Entity/Page.php +++ b/src/Entity/Page.php @@ -165,6 +165,16 @@ public function setMetaKeywords(?string $metaKeywords): void $this->getTranslation()->setMetaKeywords($metaKeywords); } + public function getMetaImage(): ?string + { + return $this->getTranslation()->getMetaImage(); + } + + public function setMetaImage(?string $metaImage): void + { + $this->getTranslation()->setMetaImage($metaImage); + } + public function getSlug(): ?string { return $this->getTranslation()->getSlug(); diff --git a/src/Entity/PageInterface.php b/src/Entity/PageInterface.php index 13b9045..65e1e9e 100644 --- a/src/Entity/PageInterface.php +++ b/src/Entity/PageInterface.php @@ -52,4 +52,8 @@ public function setMetaDescription(?string $metaDescription): void; public function getMetaKeywords(): ?string; public function setMetaKeywords(?string $metaKeywords): void; + + public function getMetaImage(): ?string; + + public function setMetaImage(?string $metaImage): void; } diff --git a/src/Entity/PageTranslation.php b/src/Entity/PageTranslation.php index 174db42..7955e98 100644 --- a/src/Entity/PageTranslation.php +++ b/src/Entity/PageTranslation.php @@ -52,6 +52,11 @@ class PageTranslation extends AbstractTranslation implements PageTranslationInte */ protected $metaDescription; + /** + * @var string|null + */ + protected $metaImage; + public function getId(): ?int { return $this->id; @@ -107,6 +112,16 @@ public function setMetaKeywords(?string $metaKeywords): void $this->metaKeywords = $metaKeywords; } + public function getMetaImage(): ?string + { + return $this->metaImage; + } + + public function setMetaImage(?string $metaImage): void + { + $this->metaImage = $metaImage; + } + public function getSlug(): ?string { return $this->slug; diff --git a/src/Entity/PageTranslationInterface.php b/src/Entity/PageTranslationInterface.php index 209567f..a0a2b7f 100644 --- a/src/Entity/PageTranslationInterface.php +++ b/src/Entity/PageTranslationInterface.php @@ -43,4 +43,8 @@ public function setMetaDescription(?string $metaDescription): void; public function getMetaKeywords(): ?string; public function setMetaKeywords(?string $metaKeywords): void; + + public function getMetaImage(): ?string; + + public function setMetaImage(?string $metaImage): void; } diff --git a/src/Form/Type/PageTranslationType.php b/src/Form/Type/PageTranslationType.php index a02a5b1..2d0049f 100644 --- a/src/Form/Type/PageTranslationType.php +++ b/src/Form/Type/PageTranslationType.php @@ -13,6 +13,7 @@ namespace MonsieurBiz\SyliusCmsPagePlugin\Form\Type; +use MonsieurBiz\SyliusMediaManagerPlugin\Form\Type\ImageType as MediaManagerImageType; use MonsieurBiz\SyliusRichEditorPlugin\Form\Type\RichEditorType; use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType; use Symfony\Component\Form\Extension\Core\Type\TextType; @@ -48,6 +49,11 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'required' => false, 'label' => 'monsieurbiz_cms_page.ui.form.meta_keywords', ]) + ->add('metaImage', MediaManagerImageType::class, [ + 'label' => 'monsieurbiz_cms_page.ui.form.meta_image', + 'help' => 'monsieurbiz_cms_page.ui.form.meta_image_help', + 'required' => false, + ]) ; } diff --git a/src/Migrations/Version20241003143537.php b/src/Migrations/Version20241003143537.php new file mode 100644 index 0000000..18c0d41 --- /dev/null +++ b/src/Migrations/Version20241003143537.php @@ -0,0 +1,40 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace MonsieurBiz\SyliusCmsPagePlugin\Migrations; + +use Doctrine\DBAL\Schema\Schema; +use Doctrine\Migrations\AbstractMigration; + +/** + * Auto-generated Migration: Please modify to your needs! + */ +final class Version20241003143537 extends AbstractMigration +{ + public function getDescription(): string + { + return ''; + } + + public function up(Schema $schema): void + { + // this up() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE monsieurbiz_cms_page_translation ADD meta_image VARCHAR(255) DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE monsieurbiz_cms_page_translation DROP meta_image'); + } +} diff --git a/src/Resources/config/config.yaml b/src/Resources/config/config.yaml index 8bb2eda..9985ee0 100644 --- a/src/Resources/config/config.yaml +++ b/src/Resources/config/config.yaml @@ -2,3 +2,4 @@ imports: - { resource: "sylius/resources.yaml" } - { resource: "sylius/grid.yaml" } - { resource: "sylius/fixtures.yaml" } + - { resource: "images.yaml" } diff --git a/src/Resources/config/doctrine/PageTranslation.orm.xml b/src/Resources/config/doctrine/PageTranslation.orm.xml index 2d237b6..5f0eeae 100644 --- a/src/Resources/config/doctrine/PageTranslation.orm.xml +++ b/src/Resources/config/doctrine/PageTranslation.orm.xml @@ -14,6 +14,7 @@ + diff --git a/src/Resources/config/images.yaml b/src/Resources/config/images.yaml new file mode 100644 index 0000000..843763f --- /dev/null +++ b/src/Resources/config/images.yaml @@ -0,0 +1,3 @@ +liip_imagine: + filter_sets: + monsieurbiz_cms_page_og_image: ~ diff --git a/src/Resources/translations/messages.en.yaml b/src/Resources/translations/messages.en.yaml index 63fc374..d23d31c 100644 --- a/src/Resources/translations/messages.en.yaml +++ b/src/Resources/translations/messages.en.yaml @@ -19,6 +19,8 @@ monsieurbiz_cms_page: meta_title: "Meta Title" meta_description: "Meta Description" meta_keywords: "Meta Keyword" + meta_image: "Meta Image" + meta_image_help: "Ideal format: 1200 x 630 px" show_in: "Show in" show_page_in_shop_page: "Show page in shop page" actions: diff --git a/src/Resources/translations/messages.fr.yaml b/src/Resources/translations/messages.fr.yaml index 35d786b..035eb1a 100644 --- a/src/Resources/translations/messages.fr.yaml +++ b/src/Resources/translations/messages.fr.yaml @@ -19,6 +19,8 @@ monsieurbiz_cms_page: meta_title: "Meta Title" meta_description: "Meta Description" meta_keywords: "Meta Keyword" + meta_image: "Meta Image" + meta_image_help: "Format idéal : 1200 x 630 px" show_in: "Afficher dans" show_page_in_shop_page: "Afficher la page dans la boutique" actions: diff --git a/src/Resources/translations/messages.pl.yaml b/src/Resources/translations/messages.pl.yaml index 7829e13..8c21b53 100644 --- a/src/Resources/translations/messages.pl.yaml +++ b/src/Resources/translations/messages.pl.yaml @@ -19,6 +19,8 @@ monsieurbiz_cms_page: meta_title: "Tytuł meta" meta_description: "Opis meta" meta_keywords: "Słowa kluczowe meta" + meta_image: "Obraz meta" + meta_image_help: "Idealny format: 1200 x 630 px" show_in: "Pokaż w" show_page_in_shop_page: "Pokaż stronę na stronie sklepu" actions: diff --git a/src/Resources/views/Shop/Page/show.html.twig b/src/Resources/views/Shop/Page/show.html.twig index 1d023f1..06405fe 100644 --- a/src/Resources/views/Shop/Page/show.html.twig +++ b/src/Resources/views/Shop/Page/show.html.twig @@ -16,6 +16,9 @@ {% if page.metaKeywords is not empty %} {% endif %} + {% if page is not empty and page.metaImage is not empty %} + + {% endif %} {% endblock %} {% block content %}