Skip to content

Commit

Permalink
Fix CS
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbager committed Jul 15, 2018
1 parent 3bc89e6 commit 0b669ab
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 20 deletions.
2 changes: 1 addition & 1 deletion spec/Entity/MediaTranslationSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
44 changes: 44 additions & 0 deletions spec/Twig/Parser/ContentParserSpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace spec\BitBag\SyliusCmsPlugin\Twig\Parser;

use BitBag\SyliusCmsPlugin\Twig\Extension\RenderBlockExtension;
use BitBag\SyliusCmsPlugin\Twig\Parser\ContentParser;
use BitBag\SyliusCmsPlugin\Twig\Parser\ContentParserInterface;
use PhpSpec\ObjectBehavior;

final class ContentParserSpec extends ObjectBehavior
{
function let(\Twig_Environment $twigEnvironment): void
{
$this->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);
}
}
2 changes: 1 addition & 1 deletion src/Assigner/ChannelsAssigner.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Action/Admin/ProductSearchAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/Fixture/Factory/PageFixtureFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -39,7 +39,7 @@ final class PageFixtureFactory implements FixtureFactoryInterface
/** @var SectionRepositoryInterface */
private $sectionRepository;

/** @var ProductRepositoryInterface */
/** @var ImageUploaderInterface */
private $imageUploader;

/** @var ProductRepositoryInterface */
Expand Down
2 changes: 1 addition & 1 deletion src/Importer/PageImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 8 additions & 8 deletions src/Menu/ContentManagementMenuBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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')
;
}
}
4 changes: 4 additions & 0 deletions src/Resources/views/Shop/Media/Show/image.html.twig
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{% set path = '/'~media.path %}

<h2>{{ media.name|raw }}</h2>

<img class="ui fluid image" src="{{ path }}" alt="{{ media.name }}"/>

<p>{{ media.description|raw }}</p>
2 changes: 1 addition & 1 deletion src/Twig/Extension/RenderBlockExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/Twig/Parser/ContentParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<div class="ui stackable two column grid">
<div class="column">
<div class="ui fluid segment column">
{{ render(path('bitbag_sylius_cms_plugin_shop_block_render', {'code' : 'homepage_header_image'})) }}
{{ bitbag_cms_render_media('homepage_header_image') }}
</div>
</div>
<div class="column">
Expand Down Expand Up @@ -47,7 +47,8 @@
<div class="column intro promo">
<div class="ui info message">
Like it? We do a lot of Sylius projects & plugins. <br/>
Perhaps there is something we can do for you. Visit <a href="https://bitbag.shop/">our website</a> for more information.
Perhaps there is something we can do for you. Visit <a href="https://bitbag.shop/">our website</a> for
more information.
</div>
</div>
</div>
Expand Down

0 comments on commit 0b669ab

Please sign in to comment.