Skip to content

Commit

Permalink
Merge pull request #172 from BitBagCommerce/dev
Browse files Browse the repository at this point in the history
Prepare 2.0.0 release
  • Loading branch information
bitbager authored Jul 15, 2018
2 parents 9fe6fe3 + 4f46e41 commit 4b379f3
Show file tree
Hide file tree
Showing 25 changed files with 124 additions and 107 deletions.
16 changes: 15 additions & 1 deletion UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
# UPGRADE FROM 1.2.1/1.1.1 to 1.2.2-dev
# UPGRADE FROM 1.0 TO 2.0

* Media type field has been removed. For image blocks, use the [media](doc/medias.md) with image type. For HTML blocks,
use raw content in [WYSIWYG editor](doc/wysiwyg.md)
* Chanel awareness has been added to pages, blocks, FAQs, sections and media. That being said, many
repository methods changed their signatures. In case you customized them in your src, check
new signatures in interfaces under [BitBag\SyliusCmsPlugin\Repository](src/Repository) namespace
* WYSIWYG editor has been introduced. You will need to import it in your AppKernel and install
its assets. For more, check the [installation guide](doc/installation.md)
* Sitemap support was added, you will need to enable extra bundle in your AppKernel. Read more
in the [sitemap documentation](doc/sitemap.md)
* Because of the possibility to [nest CMS Twig functions in the admin backend](doc/twig-functions-in-admin.md), in order to render block and page content
you are now supposed to use `bitbag_cms_render_content` Twig function

# UPGRADE FROM 1.2.1/1.1.1 to 1.2.2

* `bitbag_render_block` has been renamed to `bitbag_cms_render_block`.
* Database tables has been prefixed with `bitbag_cms` instead of `bitbag_sylius_cms_plugin` for backward compatibility and simplicity.
Expand Down
4 changes: 2 additions & 2 deletions spec/Entity/PageSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
namespace spec\BitBag\SyliusCmsPlugin\Entity;

use BitBag\SyliusCmsPlugin\Entity\Page;
use BitBag\SyliusCmsPlugin\Entity\PageContentInterface;
use BitBag\SyliusCmsPlugin\Entity\PageInterface;
use BitBag\SyliusCmsPlugin\Entity\SectionInterface;
use PhpSpec\ObjectBehavior;
use Sylius\Component\Core\Model\ChannelInterface;
Expand All @@ -34,7 +34,7 @@ function it_is_a_resource(): void

function it_implements_page_interface(): void
{
$this->shouldHaveType(PageContentInterface::class);
$this->shouldHaveType(PageInterface::class);
}

function it_allows_access_via_properties(): void
Expand Down
6 changes: 3 additions & 3 deletions spec/EventListener/PageImageUploadListenerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
namespace spec\BitBag\SyliusCmsPlugin\EventListener;

use BitBag\SyliusCmsPlugin\Entity\PageImageInterface;
use BitBag\SyliusCmsPlugin\Entity\PageContentInterface;
use BitBag\SyliusCmsPlugin\Entity\PageInterface;
use BitBag\SyliusCmsPlugin\Entity\PageTranslationInterface;
use BitBag\SyliusCmsPlugin\EventListener\PageImageUploadListener;
use Doctrine\Common\Collections\ArrayCollection;
Expand All @@ -36,7 +36,7 @@ function it_is_initializable(): void

function it_does_not_upload_if_not_page_instance(
ResourceControllerEvent $event,
PageContentInterface $page
PageInterface $page
): void {
$event->getSubject()->willReturn(Argument::any());

Expand All @@ -45,7 +45,7 @@ function it_does_not_upload_if_not_page_instance(

function it_upload_image_for_each_translations(
ResourceControllerEvent $event,
PageContentInterface $page,
PageInterface $page,
PageTranslationInterface $pageTranslation,
PageImageInterface $pageImage,
ImageUploaderInterface $pageImageUploader
Expand Down
4 changes: 2 additions & 2 deletions spec/Resolver/PageResourceResolverSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace spec\BitBag\SyliusCmsPlugin\Resolver;

use BitBag\SyliusCmsPlugin\Entity\PageContentInterface;
use BitBag\SyliusCmsPlugin\Entity\PageInterface;
use BitBag\SyliusCmsPlugin\Repository\PageRepositoryInterface;
use BitBag\SyliusCmsPlugin\Resolver\PageResourceResolver;
use BitBag\SyliusCmsPlugin\Resolver\PageResourceResolverInterface;
Expand Down Expand Up @@ -59,7 +59,7 @@ function it_logs_warning_if_page_was_not_found(
function it_returns_page_if_found_in_database(
PageRepositoryInterface $pageRepository,
LocaleContextInterface $localeContext,
PageContentInterface $page
PageInterface $page
) {
$localeContext->getLocaleCode()->willReturn('en_US');
$pageRepository->findOneEnabledByCode('homepage_banner', 'en_US')->willReturn($page);
Expand Down
4 changes: 2 additions & 2 deletions spec/Twig/Extension/RenderProductPagesExtensionSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace spec\BitBag\SyliusCmsPlugin\Twig\Extension;

use BitBag\SyliusCmsPlugin\Entity\PageContentInterface;
use BitBag\SyliusCmsPlugin\Entity\PageInterface;
use BitBag\SyliusCmsPlugin\Entity\SectionInterface;
use BitBag\SyliusCmsPlugin\Repository\PageRepositoryInterface;
use BitBag\SyliusCmsPlugin\Twig\Extension\RenderProductPagesExtension;
Expand Down Expand Up @@ -59,7 +59,7 @@ function it_renders_product_pages(
ProductInterface $product,
ChannelInterface $channel,
PageRepositoryInterface $pageRepository,
PageContentInterface $page,
PageInterface $page,
SectionInterface $section,
EngineInterface $templatingEngine
): void {
Expand Down
1 change: 0 additions & 1 deletion src/Controller/MediaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public function downloadMediaAction(Request $request): Response

$code = $request->get('code');
$mediaResourceResolver = $this->get('bitbag_sylius_cms_plugin.resolver.media_resource');

/** @var MediaInterface $media */
$media = $mediaResourceResolver->findOrLog($code);

Expand Down
4 changes: 2 additions & 2 deletions src/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace BitBag\SyliusCmsPlugin\Controller;

use BitBag\SyliusCmsPlugin\Entity\PageContentInterface;
use BitBag\SyliusCmsPlugin\Entity\PageInterface;
use FOS\RestBundle\View\View;
use Sylius\Bundle\ResourceBundle\Controller\ResourceController;
use Sylius\Component\Resource\ResourceActions;
Expand Down Expand Up @@ -67,7 +67,7 @@ public function previewAction(Request $request): Response

$form->handleRequest($request);

/** @var PageContentInterface $newResource */
/** @var PageInterface $newResource */
$newResource = $form->getData();

$defaultLocale = $this->getParameter('locale');
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Sylius\Component\Resource\Model\TranslatableTrait;
use Sylius\Component\Resource\Model\TranslationInterface;

class Page implements PageContentInterface
class Page implements PageInterface
{
use ToggleableTrait;
use ProductsAwareTrait;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Sylius\Component\Resource\Model\ToggleableInterface;
use Sylius\Component\Resource\Model\TranslatableInterface;

interface PageContentInterface extends
interface PageInterface extends
ResourceInterface,
TranslatableInterface,
ToggleableInterface,
Expand Down
4 changes: 2 additions & 2 deletions src/EventListener/PageImageUploadListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace BitBag\SyliusCmsPlugin\EventListener;

use BitBag\SyliusCmsPlugin\Entity\PageContentInterface;
use BitBag\SyliusCmsPlugin\Entity\PageInterface;
use BitBag\SyliusCmsPlugin\Entity\PageTranslationInterface;
use Sylius\Bundle\ResourceBundle\Event\ResourceControllerEvent;
use Sylius\Component\Core\Uploader\ImageUploaderInterface;
Expand All @@ -32,7 +32,7 @@ public function uploadImage(ResourceControllerEvent $event): void
{
$page = $event->getSubject();

Assert::isInstanceOf($page, PageContentInterface::class);
Assert::isInstanceOf($page, PageInterface::class);

/** @var PageTranslationInterface $translation */
foreach ($page->getTranslations() as $translation) {
Expand Down
5 changes: 2 additions & 3 deletions src/Fixture/Factory/BlockFixtureFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use BitBag\SyliusCmsPlugin\Entity\BlockInterface;
use BitBag\SyliusCmsPlugin\Entity\BlockTranslationInterface;
use BitBag\SyliusCmsPlugin\Entity\SectionInterface;
use BitBag\SyliusCmsPlugin\Factory\BlockFactoryInterface;
use BitBag\SyliusCmsPlugin\Repository\BlockRepositoryInterface;
use BitBag\SyliusCmsPlugin\Repository\SectionRepositoryInterface;
use Sylius\Component\Channel\Context\ChannelContextInterface;
Expand All @@ -25,7 +24,7 @@

final class BlockFixtureFactory implements FixtureFactoryInterface
{
/** @var BlockFactoryInterface */
/** @var FactoryInterface */
private $blockFactory;

/** @var FactoryInterface */
Expand All @@ -47,7 +46,7 @@ final class BlockFixtureFactory implements FixtureFactoryInterface
private $localeContext;

public function __construct(
BlockFactoryInterface $blockFactory,
FactoryInterface $blockFactory,
FactoryInterface $blockTranslationFactory,
BlockRepositoryInterface $blockRepository,
SectionRepositoryInterface $sectionRepository,
Expand Down
10 changes: 10 additions & 0 deletions src/Fixture/Factory/MediaFixtureFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
use BitBag\SyliusCmsPlugin\Assigner\SectionsAssignerInterface;
use BitBag\SyliusCmsPlugin\Entity\MediaInterface;
use BitBag\SyliusCmsPlugin\Entity\MediaTranslationInterface;
use BitBag\SyliusCmsPlugin\MediaProvider\ProviderInterface;
use BitBag\SyliusCmsPlugin\Repository\MediaRepositoryInterface;
use Sylius\Component\Resource\Factory\FactoryInterface;
use Symfony\Component\HttpFoundation\File\File;

final class MediaFixtureFactory implements FixtureFactoryInterface
{
Expand All @@ -27,6 +29,9 @@ final class MediaFixtureFactory implements FixtureFactoryInterface
/** @var FactoryInterface */
private $mediaTranslationFactory;

/** @var ProviderInterface */
private $imageProvider;

/** @var MediaRepositoryInterface */
private $mediaRepository;

Expand All @@ -39,12 +44,14 @@ final class MediaFixtureFactory implements FixtureFactoryInterface
public function __construct(
FactoryInterface $mediaFactory,
FactoryInterface $mediaTranslationFactory,
ProviderInterface $imageProvider,
MediaRepositoryInterface $mediaRepository,
ProductsAssignerInterface $productsAssigner,
SectionsAssignerInterface $sectionsAssigner
) {
$this->mediaFactory = $mediaFactory;
$this->mediaTranslationFactory = $mediaTranslationFactory;
$this->imageProvider = $imageProvider;
$this->mediaRepository = $mediaRepository;
$this->productsAssigner = $productsAssigner;
$this->sectionsAssigner = $sectionsAssigner;
Expand Down Expand Up @@ -77,6 +84,9 @@ private function createMedia(string $code, array $mediaData): void
$media->setType($mediaData['type']);
$media->setCode($code);
$media->setEnabled($mediaData['enabled']);
$media->setFile(new File($mediaData['path']));

$this->imageProvider->upload($media);

foreach ($mediaData['translations'] as $localeCode => $translation) {
/** @var MediaTranslationInterface $mediaTranslation */
Expand Down
8 changes: 4 additions & 4 deletions src/Fixture/Factory/PageFixtureFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace BitBag\SyliusCmsPlugin\Fixture\Factory;

use BitBag\SyliusCmsPlugin\Entity\PageContentInterface;
use BitBag\SyliusCmsPlugin\Entity\PageInterface;
use BitBag\SyliusCmsPlugin\Entity\PageImage;
use BitBag\SyliusCmsPlugin\Entity\PageTranslationInterface;
use BitBag\SyliusCmsPlugin\Entity\SectionInterface;
Expand Down Expand Up @@ -93,7 +93,7 @@ public function load(array $data): void

private function createPage(string $code, array $pageData, bool $generateSlug = false): void
{
/** @var PageContentInterface $page */
/** @var PageInterface $page */
$page = $this->pageFactory->createNew();
$products = $pageData['products'];

Expand Down Expand Up @@ -136,7 +136,7 @@ private function createPage(string $code, array $pageData, bool $generateSlug =
$this->pageRepository->add($page);
}

private function resolveProducts(PageContentInterface $page, int $limit): void
private function resolveProducts(PageInterface $page, int $limit): void
{
$products = $this->productRepository->findLatestByChannel(
$this->channelContext->getChannel(),
Expand All @@ -149,7 +149,7 @@ private function resolveProducts(PageContentInterface $page, int $limit): void
}
}

private function resolveSections(PageContentInterface $page, array $sections): void
private function resolveSections(PageInterface $page, array $sections): void
{
foreach ($sections as $sectionCode) {
/** @var SectionInterface $section */
Expand Down
1 change: 0 additions & 1 deletion src/Fixture/MediaFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ protected function configureOptionsNode(ArrayNodeDefinition $optionsNode): void
->children()
->booleanNode('remove_existing')->defaultTrue()->end()
->integerNode('number')->defaultNull()->end()
->booleanNode('code')->isRequired()->cannotBeEmpty()->end()
->scalarNode('type')->isRequired()->cannotBeEmpty()->end()
->scalarNode('path')->isRequired()->cannotBeEmpty()->end()
->booleanNode('enabled')->defaultTrue()->end()
Expand Down
6 changes: 3 additions & 3 deletions src/Importer/PageImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
namespace BitBag\SyliusCmsPlugin\Importer;

use BitBag\SyliusCmsPlugin\Downloader\ImageDownloaderInterface;
use BitBag\SyliusCmsPlugin\Entity\PageContentInterface;
use BitBag\SyliusCmsPlugin\Entity\PageInterface;
use BitBag\SyliusCmsPlugin\Entity\PageImage;
use BitBag\SyliusCmsPlugin\Entity\PageTranslationInterface;
use BitBag\SyliusCmsPlugin\Resolver\ImporterChannelsResolverInterface;
Expand Down Expand Up @@ -86,7 +86,7 @@ public function import(array $row): void
$code = $this->getColumnValue(self::CODE_COLUMN, $row);
Assert::notNull($code);

/** @var PageContentInterface $page */
/** @var PageInterface $page */
$page = $this->pageResourceResolver->getResource($code);

$page->setCode($code);
Expand Down Expand Up @@ -125,7 +125,7 @@ public function getResourceCode(): string
return 'page';
}

private function resolveImage(PageContentInterface $page, string $url, string $locale): void
private function resolveImage(PageInterface $page, string $url, string $locale): void
{
/** @var PageTranslationInterface $pageTranslation */
$pageTranslation = $page->getTranslation($locale);
Expand Down
6 changes: 3 additions & 3 deletions src/Repository/PageRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace BitBag\SyliusCmsPlugin\Repository;

use BitBag\SyliusCmsPlugin\Entity\PageContentInterface;
use BitBag\SyliusCmsPlugin\Entity\PageInterface;
use Doctrine\ORM\QueryBuilder;
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository;
use Sylius\Component\Core\Model\ProductInterface;
Expand Down Expand Up @@ -40,7 +40,7 @@ public function findEnabled(bool $enabled): array
;
}

public function findOneEnabledByCode(string $code, ?string $localeCode): ?PageContentInterface
public function findOneEnabledByCode(string $code, ?string $localeCode): ?PageInterface
{
return $this->createQueryBuilder('o')
->leftJoin('o.translations', 'translation')
Expand All @@ -58,7 +58,7 @@ public function findOneEnabledBySlugAndChannelCode(
string $slug,
?string $localeCode,
string $channelCode
): ?PageContentInterface {
): ?PageInterface {
return $this->createQueryBuilder('o')
->leftJoin('o.translations', 'translation')
->innerJoin('o.channels', 'channels')
Expand Down
6 changes: 3 additions & 3 deletions src/Repository/PageRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace BitBag\SyliusCmsPlugin\Repository;

use BitBag\SyliusCmsPlugin\Entity\PageContentInterface;
use BitBag\SyliusCmsPlugin\Entity\PageInterface;
use Doctrine\ORM\QueryBuilder;
use Sylius\Component\Core\Model\ProductInterface;
use Sylius\Component\Resource\Repository\RepositoryInterface;
Expand All @@ -23,13 +23,13 @@ public function createListQueryBuilder(string $locale): QueryBuilder;

public function findEnabled(bool $enabled): array;

public function findOneEnabledByCode(string $code, ?string $localeCode): ?PageContentInterface;
public function findOneEnabledByCode(string $code, ?string $localeCode): ?PageInterface;

public function findOneEnabledBySlugAndChannelCode(
string $slug,
?string $localeCode,
string $channelCode
): ?PageContentInterface;
): ?PageInterface;

public function createShopListQueryBuilder(string $sectionCode, string $channelCode): QueryBuilder;

Expand Down
6 changes: 3 additions & 3 deletions src/Resolver/PageResourceResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace BitBag\SyliusCmsPlugin\Resolver;

use BitBag\SyliusCmsPlugin\Entity\PageContentInterface;
use BitBag\SyliusCmsPlugin\Entity\PageInterface;
use BitBag\SyliusCmsPlugin\Repository\PageRepositoryInterface;
use Psr\Log\LoggerInterface;
use Sylius\Component\Locale\Context\LocaleContextInterface;
Expand All @@ -38,11 +38,11 @@ public function __construct(
$this->logger = $logger;
}

public function findOrLog(string $code): ?PageContentInterface
public function findOrLog(string $code): ?PageInterface
{
$page = $this->pageRepository->findOneEnabledByCode($code, $this->localeContext->getLocaleCode());

if (false === $page instanceof PageContentInterface) {
if (false === $page instanceof PageInterface) {
$this->logger->warning(sprintf(
'Page with "%s" code was not found in the database.',
$code
Expand Down
4 changes: 2 additions & 2 deletions src/Resolver/PageResourceResolverInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

namespace BitBag\SyliusCmsPlugin\Resolver;

use BitBag\SyliusCmsPlugin\Entity\PageContentInterface;
use BitBag\SyliusCmsPlugin\Entity\PageInterface;

interface PageResourceResolverInterface
{
public function findOrLog(string $code): ?PageContentInterface;
public function findOrLog(string $code): ?PageInterface;
}
Loading

0 comments on commit 4b379f3

Please sign in to comment.