diff --git a/spec/Entity/MediaTranslationSpec.php b/spec/Entity/MediaTranslationSpec.php index 15fa927d7..6492eac4e 100755 --- a/spec/Entity/MediaTranslationSpec.php +++ b/spec/Entity/MediaTranslationSpec.php @@ -37,7 +37,7 @@ function it_implements_media_translation_interface(): void $this->shouldHaveType(TranslationInterface::class); } - function it_allows_access_via_properties(PageImageInterface $pageImage): void + function it_allows_access_via_properties(): void { $this->setName('Video'); $this->getName()->shouldReturn('Video'); diff --git a/spec/Twig/Parser/ContentParserSpec.php b/spec/Twig/Parser/ContentParserSpec.php new file mode 100644 index 000000000..d48e53799 --- /dev/null +++ b/spec/Twig/Parser/ContentParserSpec.php @@ -0,0 +1,44 @@ +beConstructedWith($twigEnvironment, ['bitbag_cms_render_block']); + } + + function it_is_initializable(): void + { + $this->shouldHaveType(ContentParser::class); + } + + function it_implements_content_parser_interface(): void + { + $this->shouldHaveType(ContentParserInterface::class); + } + + function it_parses_string_functions( + \Twig_Environment $twigEnvironment, + \Twig_Function $renderBlockFunction, + RenderBlockExtension $renderBlockExtension + ): void + { + $twigEnvironment->getFunctions()->willReturn([ + 'bitbag_cms_render_block' => $renderBlockFunction, + ]); + $renderBlockFunction->getCallable()->willReturn([$renderBlockExtension, 'renderBlock']); + + $input = "Let's render! {{ bitbag_cms_render_block('intro', '@BitBagSyliusCmsPlugin/Shop/Block/show.html.twig') }}"; + + $renderBlockExtension->renderBlock('intro', '@BitBagSyliusCmsPlugin/Shop/Block/show.html.twig')->shouldBeCalled(); + + $this->parse($input); + } +} diff --git a/src/Assigner/ChannelsAssigner.php b/src/Assigner/ChannelsAssigner.php index 6eb4e591a..05beac626 100644 --- a/src/Assigner/ChannelsAssigner.php +++ b/src/Assigner/ChannelsAssigner.php @@ -29,7 +29,7 @@ public function __construct(ChannelRepositoryInterface $channelRepository) public function assign(ChannelsAwareInterface $channelsAware, array $channelsCodes): void { foreach ($channelsCodes as $channelCode) { - /** @var ChannelInterface $channel */ + /** @var ChannelInterface $channel|null */ $channel = $this->channelRepository->findOneBy(['code' => $channelCode]); if (null !== $channel) { diff --git a/src/Controller/Action/Admin/ProductSearchAction.php b/src/Controller/Action/Admin/ProductSearchAction.php index fd13b1a70..94528a12c 100644 --- a/src/Controller/Action/Admin/ProductSearchAction.php +++ b/src/Controller/Action/Admin/ProductSearchAction.php @@ -34,8 +34,8 @@ public function __construct(ProductRepositoryInterface $productRepository, ViewH public function __invoke(Request $request): Response { - $resource = $this->productRepository->findByNamePart($request->get('phrase', '')); - $view = View::create($resource); + $product = $this->productRepository->findByNamePart($request->get('phrase', '')); + $view = View::create($product); $this->viewHandler->setExclusionStrategyGroups(['Autocomplete']); $view->getContext()->enableMaxDepth(); diff --git a/src/Fixture/Factory/PageFixtureFactory.php b/src/Fixture/Factory/PageFixtureFactory.php index 6b96f61ed..6a1f58cc5 100755 --- a/src/Fixture/Factory/PageFixtureFactory.php +++ b/src/Fixture/Factory/PageFixtureFactory.php @@ -12,8 +12,8 @@ namespace BitBag\SyliusCmsPlugin\Fixture\Factory; -use BitBag\SyliusCmsPlugin\Entity\PageInterface; use BitBag\SyliusCmsPlugin\Entity\PageImage; +use BitBag\SyliusCmsPlugin\Entity\PageInterface; use BitBag\SyliusCmsPlugin\Entity\PageTranslationInterface; use BitBag\SyliusCmsPlugin\Entity\SectionInterface; use BitBag\SyliusCmsPlugin\Repository\PageRepositoryInterface; @@ -39,7 +39,7 @@ final class PageFixtureFactory implements FixtureFactoryInterface /** @var SectionRepositoryInterface */ private $sectionRepository; - /** @var ProductRepositoryInterface */ + /** @var ImageUploaderInterface */ private $imageUploader; /** @var ProductRepositoryInterface */ diff --git a/src/Importer/PageImporter.php b/src/Importer/PageImporter.php index b38d37927..baf7231b9 100644 --- a/src/Importer/PageImporter.php +++ b/src/Importer/PageImporter.php @@ -13,8 +13,8 @@ namespace BitBag\SyliusCmsPlugin\Importer; use BitBag\SyliusCmsPlugin\Downloader\ImageDownloaderInterface; -use BitBag\SyliusCmsPlugin\Entity\PageInterface; use BitBag\SyliusCmsPlugin\Entity\PageImage; +use BitBag\SyliusCmsPlugin\Entity\PageInterface; use BitBag\SyliusCmsPlugin\Entity\PageTranslationInterface; use BitBag\SyliusCmsPlugin\Resolver\ImporterChannelsResolverInterface; use BitBag\SyliusCmsPlugin\Resolver\ImporterProductsResolverInterface; diff --git a/src/Menu/ContentManagementMenuBuilder.php b/src/Menu/ContentManagementMenuBuilder.php index ad8eea5bd..e1b3af81a 100755 --- a/src/Menu/ContentManagementMenuBuilder.php +++ b/src/Menu/ContentManagementMenuBuilder.php @@ -33,6 +33,14 @@ public function buildMenu(MenuBuilderEvent $menuBuilderEvent): void ->setLabelAttribute('icon', 'block layout') ; + $cmsRootMenuItem + ->addChild('media', [ + 'route' => 'bitbag_sylius_cms_plugin_admin_media_index', + ]) + ->setLabel('bitbag_sylius_cms_plugin.ui.media') + ->setLabelAttribute('icon', 'file') + ; + $cmsRootMenuItem ->addChild('pages', [ 'route' => 'bitbag_sylius_cms_plugin_admin_page_index', @@ -56,13 +64,5 @@ public function buildMenu(MenuBuilderEvent $menuBuilderEvent): void ->setLabel('bitbag_sylius_cms_plugin.ui.sections') ->setLabelAttribute('icon', 'grid layout') ; - - $cmsRootMenuItem - ->addChild('media', [ - 'route' => 'bitbag_sylius_cms_plugin_admin_media_index', - ]) - ->setLabel('bitbag_sylius_cms_plugin.ui.media') - ->setLabelAttribute('icon', 'file') - ; } } diff --git a/src/Resources/views/Shop/Media/Show/image.html.twig b/src/Resources/views/Shop/Media/Show/image.html.twig index 7320a5057..67177e09f 100755 --- a/src/Resources/views/Shop/Media/Show/image.html.twig +++ b/src/Resources/views/Shop/Media/Show/image.html.twig @@ -1,3 +1,7 @@ {% set path = '/'~media.path %} +
{{ media.description|raw }}
diff --git a/src/Twig/Extension/RenderBlockExtension.php b/src/Twig/Extension/RenderBlockExtension.php index 822ea5ef4..d2e1481cb 100644 --- a/src/Twig/Extension/RenderBlockExtension.php +++ b/src/Twig/Extension/RenderBlockExtension.php @@ -16,7 +16,7 @@ use BitBag\SyliusCmsPlugin\Resolver\BlockResourceResolverInterface; use Symfony\Component\Templating\EngineInterface; -final class RenderBlockExtension extends \Twig_Extension +class RenderBlockExtension extends \Twig_Extension { /** @var BlockRepositoryInterface */ private $blockRepository; diff --git a/src/Twig/Parser/ContentParser.php b/src/Twig/Parser/ContentParser.php index b9319260a..f3cea4c22 100644 --- a/src/Twig/Parser/ContentParser.php +++ b/src/Twig/Parser/ContentParser.php @@ -60,7 +60,7 @@ private function getFunctionArguments(string $functionName, string $input): ?arr $arguments = explode(',', $functionParts[0]); return array_map(function (string $element): string { - return trim($element, '\''); + return trim(trim($element), '\''); }, $arguments); } @@ -76,6 +76,6 @@ private function callFunction(array $functions, string $functionName, array $arg $extension = $callable[0]; $extensionMethod = $callable[1]; - return $extension->$extensionMethod(...$arguments); + return call_user_func_array([$extension, $extensionMethod], $arguments); } } diff --git a/tests/Application/app/Resources/SyliusShopBundle/views/Homepage/index.html.twig b/tests/Application/app/Resources/SyliusShopBundle/views/Homepage/index.html.twig index 1047e5edb..d86a7647f 100755 --- a/tests/Application/app/Resources/SyliusShopBundle/views/Homepage/index.html.twig +++ b/tests/Application/app/Resources/SyliusShopBundle/views/Homepage/index.html.twig @@ -13,7 +13,7 @@