Skip to content

Commit e860306

Browse files
authored
Merge branch '3.0' into fix/remove-sitemap
2 parents 9745f3f + ec68352 commit e860306

25 files changed

Lines changed: 282 additions & 102 deletions

UPGRADE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
* The `stefandoorn/sitemap-plugin` dependency has been removed, and moved to the `suggest` section of composer.json.
44
If you didn't require this plugin by yourselves, but want to keep the sitemap support, consider requiring it directly in your project as described [here](doc/sitemap.md).
55

6+
* Width and height has been added to image media. Now width and height html tags are generated in shop image.
7+
Read the below changelog first and then migrate your structure using
8+
`bin/console doctrine:migrations:diff && bin/console doctrine:migrations:migrate` commands
9+
610
# UPGRADE FROM 1.0 TO 2.0
711

812
* A lot of database modifications has been made. Read the below changelog first and then migrate your

spec/Twig/Extension/RenderBlockExtensionSpec.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,19 @@
1313
namespace spec\BitBag\SyliusCmsPlugin\Twig\Extension;
1414

1515
use BitBag\SyliusCmsPlugin\Twig\Extension\RenderBlockExtension;
16+
use BitBag\SyliusCmsPlugin\Twig\Runtime\RenderBlockRuntimeInterface;
1617
use PhpSpec\ObjectBehavior;
1718
use Twig\Extension\AbstractExtension;
1819
use Twig\TwigFunction;
1920

2021
final class RenderBlockExtensionSpec extends ObjectBehavior
2122
{
23+
function let(
24+
RenderBlockRuntimeInterface $blockRuntime
25+
) {
26+
$this->beConstructedWith($blockRuntime);
27+
}
28+
2229
function it_is_initializable(): void
2330
{
2431
$this->shouldHaveType(RenderBlockExtension::class);

spec/Twig/Extension/RenderMediaExtensionSpec.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,19 @@
1313
namespace spec\BitBag\SyliusCmsPlugin\Twig\Extension;
1414

1515
use BitBag\SyliusCmsPlugin\Twig\Extension\RenderMediaExtension;
16+
use BitBag\SyliusCmsPlugin\Twig\Runtime\RenderMediaRuntimeInterface;
1617
use PhpSpec\ObjectBehavior;
1718
use Twig\Extension\AbstractExtension;
1819
use Twig\TwigFunction;
1920

2021
final class RenderMediaExtensionSpec extends ObjectBehavior
2122
{
23+
function let(
24+
RenderMediaRuntimeInterface $mediaRuntime
25+
) {
26+
$this->beConstructedWith($mediaRuntime);
27+
}
28+
2229
function it_is_initializable(): void
2330
{
2431
$this->shouldHaveType(RenderMediaExtension::class);

spec/Twig/Parser/ContentParserSpec.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function it_implements_content_parser_interface(): void
2626
$this->shouldHaveType(ContentParserInterface::class);
2727
}
2828

29-
function it_parses_string_functions(
29+
function it_parses_string_function(
3030
Environment $twigEnvironment,
3131
TwigFunction $renderBlockFunction,
3232
RenderBlockRuntimeInterface $renderBlockRuntime
@@ -43,4 +43,24 @@ function it_parses_string_functions(
4343

4444
$this->parse($input);
4545
}
46+
47+
function it_parses_string_functions(
48+
Environment $twigEnvironment,
49+
TwigFunction $renderBlockFunction,
50+
RenderBlockRuntimeInterface $renderBlockRuntime
51+
): void
52+
{
53+
$twigEnvironment->getFunctions()->willReturn([
54+
'bitbag_cms_render_block' => $renderBlockFunction,
55+
]);
56+
$renderBlockFunction->getCallable()->willReturn([$renderBlockRuntime, 'renderBlock']);
57+
58+
$input = "Let's render! {{ bitbag_cms_render_block('intro', '@BitBagSyliusCmsPlugin/Shop/Block/show.html.twig') }}
59+
Let's render twice! {{ bitbag_cms_render_block('intro1', '@BitBagSyliusCmsPlugin/Shop/Block/show.html.twig') }}";
60+
61+
$renderBlockRuntime->renderBlock('intro', '@BitBagSyliusCmsPlugin/Shop/Block/show.html.twig')->shouldBeCalled();
62+
$renderBlockRuntime->renderBlock('intro1', '@BitBagSyliusCmsPlugin/Shop/Block/show.html.twig')->shouldBeCalled();
63+
64+
$this->parse($input);
65+
}
4666
}

src/Entity/Media.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ class Media implements MediaInterface
4949
/** @var string */
5050
protected $originalPath;
5151

52+
/** @var int|null */
53+
protected $width;
54+
55+
/** @var int|null */
56+
protected $height;
57+
5258
public function __construct()
5359
{
5460
$this->initializeTranslationsCollection();
@@ -162,6 +168,26 @@ public function setLink(?string $link): void
162168
$this->getMediaTranslation()->setLink($link);
163169
}
164170

171+
public function getWidth(): ?int
172+
{
173+
return $this->width;
174+
}
175+
176+
public function setWidth(?int $width): void
177+
{
178+
$this->width = $width;
179+
}
180+
181+
public function getHeight(): ?int
182+
{
183+
return $this->height;
184+
}
185+
186+
public function setHeight(?int $height): void
187+
{
188+
$this->height = $height;
189+
}
190+
165191
/**
166192
* @return MediaTranslationInterface|TranslationInterface
167193
*/
@@ -174,7 +200,7 @@ protected function createTranslation(): MediaTranslationInterface
174200
{
175201
return new MediaTranslation();
176202
}
177-
203+
178204
public function __toString(): string
179205
{
180206
return $this->getName() ?? $this->code;

src/Entity/MediaInterface.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,12 @@ public function setAlt(?string $alt): void;
7272
public function getLink(): ?string;
7373

7474
public function setLink(?string $link): void;
75+
76+
public function getWidth(): ?int;
77+
78+
public function setWidth(?int $width): void;
79+
80+
public function getHeight(): ?int;
81+
82+
public function setHeight(?int $height): void;
7583
}

src/Entity/Page.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,14 @@ public function setTitle(?string $title): void
166166
}
167167

168168
/**
169-
* @return PageTranslationInterface|TranslationInterface|null
169+
* @return PageTranslationInterface|TranslationInterface
170170
*/
171171
protected function getPageTranslation(): PageTranslationInterface
172172
{
173173
return $this->getTranslation();
174174
}
175175

176-
protected function createTranslation(): ?PageTranslationInterface
176+
protected function createTranslation(): PageTranslationInterface
177177
{
178178
return new PageTranslation();
179179
}

src/Resources/config/config.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,9 @@ sylius_ui:
3232
javascripts:
3333
template: "@BitBagSyliusCmsPlugin/_javascripts.html.twig"
3434
priority: 10
35+
liip_imagine:
36+
loaders:
37+
default:
38+
filesystem:
39+
data_root:
40+
- "%kernel.project_dir%/public"

src/Resources/config/doctrine/Media.orm.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ BitBag\SyliusCmsPlugin\Entity\Media:
3030
enabled:
3131
column: enabled
3232
type: boolean
33+
width:
34+
column: width
35+
type: integer
36+
nullable: true
37+
height:
38+
column: height
39+
type: integer
40+
nullable: true
41+
3342
manyToMany:
3443
sections:
3544
targetEntity: BitBag\SyliusCmsPlugin\Entity\SectionInterface

src/Resources/config/services/twig.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ parameters:
77
services:
88
bitbag_sylius_cms_plugin.twig.extension.block:
99
class: BitBag\SyliusCmsPlugin\Twig\Extension\RenderBlockExtension
10+
arguments:
11+
- "@bitbag_sylius_cms_plugin.twig.runtime.block"
1012
tags:
1113
- { name: twig.extension }
1214

@@ -21,6 +23,8 @@ services:
2123

2224
bitbag_sylius_cms_plugin.twig.extension.media:
2325
class: BitBag\SyliusCmsPlugin\Twig\Extension\RenderMediaExtension
26+
arguments:
27+
- "@bitbag_sylius_cms_plugin.twig.runtime.media"
2428
tags:
2529
- { name: twig.extension }
2630

0 commit comments

Comments
 (0)