Skip to content

Commit 8739c74

Browse files
authored
Merge pull request #76 from maximehuran/feature/add-meta-image
Add meta image managed by media manager
2 parents e5123db + f3aa87b commit 8739c74

File tree

14 files changed

+94
-0
lines changed

14 files changed

+94
-0
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"license": "MIT",
77
"require": {
88
"monsieurbiz/sylius-plus-adapter-plugin": "^1.1",
9+
"monsieurbiz/sylius-media-manager-plugin": "^1.1",
910
"monsieurbiz/sylius-rich-editor-plugin": "^2.8",
1011
"php": "^8.0",
1112
"sylius/sylius": ">=1.11 <1.14"

src/Entity/Page.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,16 @@ public function setMetaKeywords(?string $metaKeywords): void
165165
$this->getTranslation()->setMetaKeywords($metaKeywords);
166166
}
167167

168+
public function getMetaImage(): ?string
169+
{
170+
return $this->getTranslation()->getMetaImage();
171+
}
172+
173+
public function setMetaImage(?string $metaImage): void
174+
{
175+
$this->getTranslation()->setMetaImage($metaImage);
176+
}
177+
168178
public function getSlug(): ?string
169179
{
170180
return $this->getTranslation()->getSlug();

src/Entity/PageInterface.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,8 @@ public function setMetaDescription(?string $metaDescription): void;
5252
public function getMetaKeywords(): ?string;
5353

5454
public function setMetaKeywords(?string $metaKeywords): void;
55+
56+
public function getMetaImage(): ?string;
57+
58+
public function setMetaImage(?string $metaImage): void;
5559
}

src/Entity/PageTranslation.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ class PageTranslation extends AbstractTranslation implements PageTranslationInte
5252
*/
5353
protected $metaDescription;
5454

55+
/**
56+
* @var string|null
57+
*/
58+
protected $metaImage;
59+
5560
public function getId(): ?int
5661
{
5762
return $this->id;
@@ -107,6 +112,16 @@ public function setMetaKeywords(?string $metaKeywords): void
107112
$this->metaKeywords = $metaKeywords;
108113
}
109114

115+
public function getMetaImage(): ?string
116+
{
117+
return $this->metaImage;
118+
}
119+
120+
public function setMetaImage(?string $metaImage): void
121+
{
122+
$this->metaImage = $metaImage;
123+
}
124+
110125
public function getSlug(): ?string
111126
{
112127
return $this->slug;

src/Entity/PageTranslationInterface.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,8 @@ public function setMetaDescription(?string $metaDescription): void;
4343
public function getMetaKeywords(): ?string;
4444

4545
public function setMetaKeywords(?string $metaKeywords): void;
46+
47+
public function getMetaImage(): ?string;
48+
49+
public function setMetaImage(?string $metaImage): void;
4650
}

src/Form/Type/PageTranslationType.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace MonsieurBiz\SyliusCmsPagePlugin\Form\Type;
1515

16+
use MonsieurBiz\SyliusMediaManagerPlugin\Form\Type\ImageType as MediaManagerImageType;
1617
use MonsieurBiz\SyliusRichEditorPlugin\Form\Type\RichEditorType;
1718
use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType;
1819
use Symfony\Component\Form\Extension\Core\Type\TextType;
@@ -48,6 +49,11 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
4849
'required' => false,
4950
'label' => 'monsieurbiz_cms_page.ui.form.meta_keywords',
5051
])
52+
->add('metaImage', MediaManagerImageType::class, [
53+
'label' => 'monsieurbiz_cms_page.ui.form.meta_image',
54+
'help' => 'monsieurbiz_cms_page.ui.form.meta_image_help',
55+
'required' => false,
56+
])
5157
;
5258
}
5359

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
/*
4+
* This file is part of Monsieur Biz' Cms Page plugin for Sylius.
5+
*
6+
* (c) Monsieur Biz <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE.txt
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace MonsieurBiz\SyliusCmsPagePlugin\Migrations;
15+
16+
use Doctrine\DBAL\Schema\Schema;
17+
use Doctrine\Migrations\AbstractMigration;
18+
19+
/**
20+
* Auto-generated Migration: Please modify to your needs!
21+
*/
22+
final class Version20241003143537 extends AbstractMigration
23+
{
24+
public function getDescription(): string
25+
{
26+
return '';
27+
}
28+
29+
public function up(Schema $schema): void
30+
{
31+
// this up() migration is auto-generated, please modify it to your needs
32+
$this->addSql('ALTER TABLE monsieurbiz_cms_page_translation ADD meta_image VARCHAR(255) DEFAULT NULL');
33+
}
34+
35+
public function down(Schema $schema): void
36+
{
37+
// this down() migration is auto-generated, please modify it to your needs
38+
$this->addSql('ALTER TABLE monsieurbiz_cms_page_translation DROP meta_image');
39+
}
40+
}

src/Resources/config/config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ imports:
22
- { resource: "sylius/resources.yaml" }
33
- { resource: "sylius/grid.yaml" }
44
- { resource: "sylius/fixtures.yaml" }
5+
- { resource: "images.yaml" }

src/Resources/config/doctrine/PageTranslation.orm.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<field name="slug" length="255" nullable="true" />
1515
<field name="metaTitle" column="meta_title" length="255" nullable="true" />
1616
<field name="metaKeywords" column="meta_keywords" length="255" nullable="true" />
17+
<field name="metaImage" column="meta_image" nullable="true" />
1718
<field name="metaDescription" column="meta_description" type="text" nullable="true" />
1819
</mapped-superclass>
1920

src/Resources/config/images.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
liip_imagine:
2+
filter_sets:
3+
monsieurbiz_cms_page_og_image: ~

0 commit comments

Comments
 (0)