Skip to content

Commit 8153edf

Browse files
committed
Update subscribers
1 parent 7cd4cdf commit 8153edf

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/EventSubscriber/OpenGraph/AddChannelInformationSubscriber.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66

77
use Setono\SyliusSEOPlugin\OpenGraph\OpenGraph;
88
use Sylius\Component\Channel\Context\ChannelContextInterface;
9+
use Sylius\Component\Locale\Context\LocaleContextInterface;
910
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1011
use Symfony\Component\HttpKernel\KernelEvents;
1112

1213
final class AddChannelInformationSubscriber implements EventSubscriberInterface
1314
{
1415
public function __construct(
1516
private readonly ChannelContextInterface $channelContext,
17+
private readonly LocaleContextInterface $localeContext,
1618
private readonly OpenGraph $openGraph,
1719
) {
1820
}
@@ -29,5 +31,6 @@ public function add(): void
2931
$channel = $this->channelContext->getChannel();
3032

3133
$this->openGraph->siteName((string) $channel->getName());
34+
$this->openGraph->locale($this->localeContext->getLocaleCode());
3235
}
3336
}

src/EventSubscriber/OpenGraph/AddProductInformationSubscriber.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,10 @@ public function add(ResourceControllerEvent $event): void
3333
Assert::isInstanceOf($product, ProductInterface::class);
3434

3535
$images = $this->productImagesResolver->resolve($product);
36-
if ([] === $images) {
37-
return;
36+
if ([] !== $images) {
37+
$this->openGraph->image((new Image($images[0]))->alt($product->getName()));
3838
}
3939

40-
foreach ($images as $image) {
41-
$this->openGraph->image(Image::create($image));
42-
}
40+
$this->openGraph->description($product->getDescription());
4341
}
4442
}

0 commit comments

Comments
 (0)