From 2a5542a50f7bb4832d513366ec09d51bff589d23 Mon Sep 17 00:00:00 2001 From: Maxime Huran Date: Thu, 3 Oct 2024 16:23:00 +0200 Subject: [PATCH 1/2] Add meta image managed by media manager --- composer.json | 1 + src/Entity/Homepage.php | 10 +++++ src/Entity/HomepageInterface.php | 4 ++ src/Entity/HomepageTranslation.php | 12 ++++++ src/Entity/HomepageTranslationInterface.php | 4 ++ src/Form/Type/HomepageTranslationType.php | 6 +++ src/Migrations/Version20241003135122.php | 40 +++++++++++++++++++ src/Resources/config/config.yaml | 1 + .../doctrine/HomepageTranslation.orm.xml | 1 + src/Resources/config/images.yaml | 3 ++ src/Resources/translations/messages.en.yaml | 2 + src/Resources/translations/messages.fr.yaml | 2 + src/Resources/translations/messages.nl.yaml | 2 + src/Resources/views/Homepage/index.html.twig | 3 ++ 14 files changed, 91 insertions(+) create mode 100644 src/Migrations/Version20241003135122.php create mode 100644 src/Resources/config/images.yaml diff --git a/composer.json b/composer.json index dd3d2b6..f9e9290 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/Homepage.php b/src/Entity/Homepage.php index bc2eb39..7e6728c 100644 --- a/src/Entity/Homepage.php +++ b/src/Entity/Homepage.php @@ -137,6 +137,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); + } + protected function createTranslation(): HomepageTranslation { return new HomepageTranslation(); diff --git a/src/Entity/HomepageInterface.php b/src/Entity/HomepageInterface.php index a642df5..a2334b5 100644 --- a/src/Entity/HomepageInterface.php +++ b/src/Entity/HomepageInterface.php @@ -42,4 +42,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/HomepageTranslation.php b/src/Entity/HomepageTranslation.php index 9027a2d..3fb5c95 100644 --- a/src/Entity/HomepageTranslation.php +++ b/src/Entity/HomepageTranslation.php @@ -29,6 +29,8 @@ class HomepageTranslation extends AbstractTranslation implements HomepageTransla protected ?string $metaDescription; + protected ?string $metaImage; + public function getId(): ?int { return $this->id; @@ -83,4 +85,14 @@ 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; + } } diff --git a/src/Entity/HomepageTranslationInterface.php b/src/Entity/HomepageTranslationInterface.php index 57e6667..680e6f7 100644 --- a/src/Entity/HomepageTranslationInterface.php +++ b/src/Entity/HomepageTranslationInterface.php @@ -39,4 +39,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/HomepageTranslationType.php b/src/Form/Type/HomepageTranslationType.php index 793695e..7e1d409 100644 --- a/src/Form/Type/HomepageTranslationType.php +++ b/src/Form/Type/HomepageTranslationType.php @@ -13,6 +13,7 @@ namespace MonsieurBiz\SyliusHomepagePlugin\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; @@ -45,6 +46,11 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'required' => false, 'label' => 'monsieurbiz_homepage.ui.form.meta_keywords', ]) + ->add('metaImage', MediaManagerImageType::class, [ + 'label' => 'monsieurbiz_homepage.ui.form.meta_image', + 'help' => 'monsieurbiz_homepage.ui.form.meta_image_help', + 'required' => false, + ]) ; } diff --git a/src/Migrations/Version20241003135122.php b/src/Migrations/Version20241003135122.php new file mode 100644 index 0000000..6a579f7 --- /dev/null +++ b/src/Migrations/Version20241003135122.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\SyliusHomepagePlugin\Migrations; + +use Doctrine\DBAL\Schema\Schema; +use Doctrine\Migrations\AbstractMigration; + +/** + * Auto-generated Migration: Please modify to your needs! + */ +final class Version20241003135122 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_homepage_homepage_translation ADD metaImage 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_homepage_homepage_translation DROP metaImage'); + } +} diff --git a/src/Resources/config/config.yaml b/src/Resources/config/config.yaml index 91c2bd1..adb63cd 100644 --- a/src/Resources/config/config.yaml +++ b/src/Resources/config/config.yaml @@ -2,3 +2,4 @@ imports: - { resource: "sylius/fixtures.yaml" } - { resource: "sylius/grid.yaml" } - { resource: "sylius/resources.yaml" } + - { resource: 'images.yaml' } diff --git a/src/Resources/config/doctrine/HomepageTranslation.orm.xml b/src/Resources/config/doctrine/HomepageTranslation.orm.xml index bdeaca5..48fe3f6 100644 --- a/src/Resources/config/doctrine/HomepageTranslation.orm.xml +++ b/src/Resources/config/doctrine/HomepageTranslation.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..b13f23e --- /dev/null +++ b/src/Resources/config/images.yaml @@ -0,0 +1,3 @@ +liip_imagine: + filter_sets: + monsieurbiz_homepage_og_image: ~ diff --git a/src/Resources/translations/messages.en.yaml b/src/Resources/translations/messages.en.yaml index b7da873..29dc4e6 100644 --- a/src/Resources/translations/messages.en.yaml +++ b/src/Resources/translations/messages.en.yaml @@ -14,6 +14,8 @@ monsieurbiz_homepage: meta_title: 'Meta title' meta_description: 'Meta description' meta_keywords: 'Meta keywords' + meta_image: 'Meta image' + meta_image_help: 'Ideal format: 1200 x 630 px' id: 'ID' actions: create: 'New homepage' diff --git a/src/Resources/translations/messages.fr.yaml b/src/Resources/translations/messages.fr.yaml index 0d9f613..8a42761 100644 --- a/src/Resources/translations/messages.fr.yaml +++ b/src/Resources/translations/messages.fr.yaml @@ -14,6 +14,8 @@ monsieurbiz_homepage: meta_title: 'Meta titre' meta_description: 'Meta description' meta_keywords: 'Meta mots clés' + meta_image: 'Meta image' + meta_image_help: 'Format idéal : 1200 x 630 px' id: 'ID' actions: create: 'Nouvelle page d''accueil' diff --git a/src/Resources/translations/messages.nl.yaml b/src/Resources/translations/messages.nl.yaml index ed25bec..01c6138 100644 --- a/src/Resources/translations/messages.nl.yaml +++ b/src/Resources/translations/messages.nl.yaml @@ -14,6 +14,8 @@ monsieurbiz_homepage: meta_title: 'Meta titel' meta_description: 'Meta omschrijving' meta_keywords: 'Meta keywords' + meta_image: 'Meta afbeelding' + meta_image_help: 'Ideaal formaat: 1200 x 630 px' id: 'ID' actions: create: 'Nieuwe homepagina' diff --git a/src/Resources/views/Homepage/index.html.twig b/src/Resources/views/Homepage/index.html.twig index 093ee94..66673e6 100644 --- a/src/Resources/views/Homepage/index.html.twig +++ b/src/Resources/views/Homepage/index.html.twig @@ -20,6 +20,9 @@ {% if homepages is not empty and homepages.metaKeywords is not empty %} {% endif %} + {% if homepages is not empty and homepages.metaImage is not empty %} + + {% endif %} {% endblock %} {% block content %} From 93ca3fbb02199e4a8d6ce960a436b983aa360a50 Mon Sep 17 00:00:00 2001 From: Maxime Huran Date: Thu, 3 Oct 2024 16:28:36 +0200 Subject: [PATCH 2/2] Fix docker-compose to docker compose --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 905343a..a703e1a 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ export COMPOSE_PROJECT_NAME=homepage export MIGRATIONS_NAMESPACE=MonsieurBiz\\SyliusHomepagePlugin\\Migrations export USER_UID=$(shell id -u) PLUGIN_NAME=sylius-${COMPOSE_PROJECT_NAME}-plugin -COMPOSE=docker-compose +COMPOSE=docker compose YARN=yarn ###