diff --git a/Command/InstallCommand.php b/Command/InstallCommand.php
deleted file mode 100644
index 80c81cf..0000000
--- a/Command/InstallCommand.php
+++ /dev/null
@@ -1,167 +0,0 @@
-setName('webburza:sylius-article-bundle:install')
- ->setDescription("Installs the bundle, creates required database tables.")
- ->setHelp("Usage: $ bin/console webburza:sylius-article-bundle:install ")
- ;
- }
-
- protected function execute(InputInterface $input, OutputInterface $output)
- {
- /** @var \Doctrine\ORM\EntityManager $manager */
- $manager = $this->getContainer()->get('doctrine.orm.default_entity_manager');
-
- $output->writeln('Creating article tables... ');
- $this->createArticleTables($manager);
-
- $output->writeln('Creating permissions... ');
- $this->createPermissions($manager);
-
- $output->writeln('Installation complete. ');
- }
-
- /**
- * Create article tables.
- *
- * @param $manager
- */
- private function createArticleTables($manager)
- {
- // Check if tables already exist
- $schemaManager = $manager->getConnection()->getSchemaManager();
-
- // Skipp if article table already exist
- if ($schemaManager->tablesExist(['webburza_sylius_article'])) {
- return;
- }
-
- $queries = [
- 'CREATE TABLE webburza_sylius_article (id INT AUTO_INCREMENT NOT NULL, category_id INT DEFAULT NULL, published TINYINT(1) NOT NULL, featured TINYINT(1) NOT NULL, published_at DATETIME DEFAULT NULL, created_at DATETIME DEFAULT NULL, updated_at DATETIME DEFAULT NULL, INDEX IDX_9FD397A312469DE2 (category_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
- 'CREATE TABLE webburza_sylius_article_product (product_id INT NOT NULL, article_id INT NOT NULL, INDEX IDX_2AB0C4534584665A (product_id), UNIQUE INDEX UNIQ_2AB0C4537294869C (article_id), PRIMARY KEY(product_id, article_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
- 'CREATE TABLE webburza_sylius_article_category (id INT AUTO_INCREMENT NOT NULL, published TINYINT(1) NOT NULL, created_at DATETIME DEFAULT NULL, updated_at DATETIME DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
- 'CREATE TABLE webburza_sylius_article_translation (id INT AUTO_INCREMENT NOT NULL, translatable_id INT NOT NULL, title VARCHAR(255) DEFAULT NULL, slug VARCHAR(255) DEFAULT NULL, lead LONGTEXT DEFAULT NULL, content LONGTEXT DEFAULT NULL, meta_keywords LONGTEXT DEFAULT NULL, meta_description LONGTEXT DEFAULT NULL, active TINYINT(1) NOT NULL, locale VARCHAR(255) NOT NULL, INDEX IDX_B49ACC0B2C2AC5D3 (translatable_id), UNIQUE INDEX webburza_sylius_article_translation_uniq_trans (translatable_id, locale), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
- 'CREATE TABLE webburza_sylius_article_image (id INT AUTO_INCREMENT NOT NULL, article_id INT DEFAULT NULL, path VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME DEFAULT NULL, UNIQUE INDEX UNIQ_710599397294869C (article_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
- 'CREATE TABLE webburza_sylius_article_category_translation (id INT AUTO_INCREMENT NOT NULL, translatable_id INT NOT NULL, title VARCHAR(255) DEFAULT NULL, slug VARCHAR(255) DEFAULT NULL, locale VARCHAR(255) NOT NULL, INDEX IDX_1B9F69192C2AC5D3 (translatable_id), UNIQUE INDEX webburza_sylius_article_category_translation_uniq_trans (translatable_id, locale), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
- 'ALTER TABLE webburza_sylius_article ADD CONSTRAINT FK_9FD397A312469DE2 FOREIGN KEY (category_id) REFERENCES webburza_sylius_article_category (id)',
- 'ALTER TABLE webburza_sylius_article_product ADD CONSTRAINT FK_2AB0C4534584665A FOREIGN KEY (product_id) REFERENCES webburza_sylius_article (id)',
- 'ALTER TABLE webburza_sylius_article_product ADD CONSTRAINT FK_2AB0C4537294869C FOREIGN KEY (article_id) REFERENCES sylius_product (id)',
- 'ALTER TABLE webburza_sylius_article_translation ADD CONSTRAINT FK_B49ACC0B2C2AC5D3 FOREIGN KEY (translatable_id) REFERENCES webburza_sylius_article (id) ON DELETE CASCADE',
- 'ALTER TABLE webburza_sylius_article_image ADD CONSTRAINT FK_710599397294869C FOREIGN KEY (article_id) REFERENCES webburza_sylius_article (id) ON DELETE CASCADE',
- 'ALTER TABLE webburza_sylius_article_category_translation ADD CONSTRAINT FK_1B9F69192C2AC5D3 FOREIGN KEY (translatable_id) REFERENCES webburza_sylius_article_category (id) ON DELETE CASCADE'
- ];
-
- $manager->beginTransaction();
-
- foreach ($queries as $query) {
- $statement = $manager->getConnection()->prepare($query);
- $statement->execute();
- }
-
- $manager->commit();
- }
-
- /**
- * Create all required permission entries.
- *
- * @param $manager
- */
- private function createPermissions($manager)
- {
- $repository = $this->getContainer()->get('sylius.repository.permission');
-
- // Get parent node (used for content)
- $contentPermission = $repository->findOneBy(['code' => 'sylius.content']);
-
- // Create permissions
- $articleManagePermission = $this->createArticlePermissions($contentPermission);
- $articleCategoryManagePermission = $this->createArticleCategoryPermissions($contentPermission);
-
- // Persist the permissions
- $manager->persist($articleManagePermission);
- $manager->persist($articleCategoryManagePermission);
- $manager->flush();
- }
-
- /**
- * Create permissions for Article resource.
- *
- * @param Permission $parentPermission
- * @return Permission
- */
- private function createArticlePermissions($parentPermission)
- {
- // Create main permissions node
- $managePermission = new Permission();
- $managePermission->setCode('webburza.manage.article');
- $managePermission->setDescription('Manage articles');
- $managePermission->setParent($parentPermission);
-
- // Define permissions
- $permissions = [
- 'webburza.article.show' => 'Show article',
- 'webburza.article.index' => 'List articles',
- 'webburza.article.create' => 'Create article',
- 'webburza.article.update' => 'Update article',
- 'webburza.article.delete' => 'Delete article',
- 'webburza.article_image.delete' => 'Delete article image'
- ];
-
- // Create each permission
- foreach ($permissions as $code => $description) {
- $permission = new Permission();
- $permission->setCode($code);
- $permission->setDescription($description);
-
- $managePermission->addChild($permission);
- }
-
- return $managePermission;
- }
-
- /**
- * Create permissions for Article Category resource.
- *
- * @param Permission $parentPermission
- * @return Permission
- */
- private function createArticleCategoryPermissions(Permission $parentPermission)
- {
- // Create main permissions node
- $managePermission = new Permission();
- $managePermission->setCode('webburza.manage.article_category');
- $managePermission->setDescription('Manage article categories');
- $managePermission->setParent($parentPermission);
-
- // Define permissions
- $permissions = [
- 'webburza.article_category.show' => 'Show article category',
- 'webburza.article_category.index' => 'List article categories',
- 'webburza.article_category.create' => 'Create article category',
- 'webburza.article_category.update' => 'Update article category',
- 'webburza.article_category.delete' => 'Delete article category'
- ];
-
- // Create each permission
- foreach ($permissions as $code => $description) {
- $permission = new Permission();
- $permission->setCode($code);
- $permission->setDescription($description);
-
- $managePermission->addChild($permission);
- }
-
- return $managePermission;
- }
-}
diff --git a/Command/UninstallCommand.php b/Command/UninstallCommand.php
deleted file mode 100644
index 7b9f283..0000000
--- a/Command/UninstallCommand.php
+++ /dev/null
@@ -1,99 +0,0 @@
-setName('webburza:sylius-article-bundle:uninstall')
- ->setDescription("Uninstalls the bundle, removes bundle-specific database tables and permissions.")
- ->setHelp("Usage: $ bin/console webburza:sylius-article-bundle:uninstall ")
- ;
- }
-
- /**
- * @param InputInterface $input
- * @param OutputInterface $output
- *
- * @return int|null|void
- */
- protected function execute(InputInterface $input, OutputInterface $output)
- {
- /** @var \Doctrine\ORM\EntityManager $manager */
- $manager = $this->getContainer()->get('doctrine.orm.default_entity_manager');
-
- $output->writeln('Removing article tables... ');
- $this->removeArticleTables($manager);
-
- $output->writeln('Removing permissions... ');
- $this->removePermissions($manager);
-
- $output->writeln('Uninstallation complete. ');
- }
-
- /**
- * Remove article tables.
- *
- * @param $manager
- */
- private function removeArticleTables($manager)
- {
- // Check if tables exist
- $schemaManager = $manager->getConnection()->getSchemaManager();
-
- // Skip if product group table does not exist
- if (!$schemaManager->tablesExist(['webburza_sylius_article'])) {
- return;
- }
-
- $queries = [
- 'ALTER TABLE webburza_sylius_article_product DROP FOREIGN KEY FK_2AB0C4534584665A',
- 'ALTER TABLE webburza_sylius_article_translation DROP FOREIGN KEY FK_B49ACC0B2C2AC5D3',
- 'ALTER TABLE webburza_sylius_article_image DROP FOREIGN KEY FK_710599397294869C',
- 'ALTER TABLE webburza_sylius_article DROP FOREIGN KEY FK_9FD397A312469DE2',
- 'ALTER TABLE webburza_sylius_article_category_translation DROP FOREIGN KEY FK_1B9F69192C2AC5D3',
- 'DROP TABLE webburza_sylius_article',
- 'DROP TABLE webburza_sylius_article_product',
- 'DROP TABLE webburza_sylius_article_category',
- 'DROP TABLE webburza_sylius_article_translation',
- 'DROP TABLE webburza_sylius_article_image',
- 'DROP TABLE webburza_sylius_article_category_translation'
- ];
-
- $manager->beginTransaction();
-
- foreach ($queries as $query) {
- $statement = $manager->getConnection()->prepare($query);
- $statement->execute();
- }
-
- $manager->commit();
- }
-
- /**
- * Remove permission entries.
- *
- * @param $manager
- */
- private function removePermissions($manager)
- {
- $repository = $this->getContainer()->get('sylius.repository.permission');
-
- // Get the main node to remove
- $articleManagePermission = $repository->findOneBy(['code' => 'webburza.manage.article']);
- $articleCategoryManagePermission = $repository->findOneBy(['code' => 'webburza.manage.article_category']);
-
- if ($articleManagePermission) {
- // Remove permissions
- $manager->remove($articleManagePermission);
- $manager->remove($articleCategoryManagePermission);
- $manager->flush();
- }
- }
-}
diff --git a/Controller/ArticleCategoryController.php b/Controller/ArticleCategoryController.php
deleted file mode 100644
index 10851a6..0000000
--- a/Controller/ArticleCategoryController.php
+++ /dev/null
@@ -1,66 +0,0 @@
-get('sylius.context.locale')->getCurrentLocale();
-
- // Get request configuration
- $configuration = $this->requestConfigurationFactory->create($this->metadata, $request);
-
- /** @var ArticleCategoryRepositoryInterface $repository */
- $repository = $this->repository;
-
- // Get a publicly visible article by translated slug
- $category = $repository->findPublicBySlug($slug, $locale);
-
- if (!$category) {
- throw $this->createNotFoundException();
- }
-
- /** @var ArticleRepositoryInterface $repository */
- $repository = $this->get('webburza.repository.article');
-
- // Get a paginator for publicly visible articles for locale
- $articlesPaginator = $repository->getPublicPaginatorForLocale($locale, $category);
- $articlesPaginator->setCurrentPage($this->get('request')->get('page', 1), true, true);
- $articlesPaginator->setMaxPerPage($configuration->getPaginationMaxPerPage());
-
- // Get categories for listing
- $categories = $this->get('webburza.repository.article_category')->findBy([
- 'published' => true
- ]);
-
- // Create the view
- $view = View::create();
-
- // Set template and data
- $view->setTemplate('WebburzaSyliusArticleBundle:Frontend/Category:show.html.twig');
- $view->setData(array(
- 'articles' => $articlesPaginator,
- 'category' => $category,
- 'categories' => $categories
- ));
-
- // Handle view
- return $this->viewHandler->handle($configuration, $view);
- }
-}
diff --git a/Controller/ArticleController.php b/Controller/ArticleController.php
index 7e6ce76..55fd61b 100644
--- a/Controller/ArticleController.php
+++ b/Controller/ArticleController.php
@@ -3,51 +3,58 @@
namespace Webburza\Sylius\ArticleBundle\Controller;
use FOS\RestBundle\View\View;
+use Sylius\Component\Resource\ResourceActions;
use Symfony\Component\HttpFoundation\Request;
use Sylius\Bundle\ResourceBundle\Controller\ResourceController;
+use Webburza\Sylius\ArticleBundle\Model\ArticleCategoryInterface;
use Webburza\Sylius\ArticleBundle\Model\ArticleControllerInterface;
-use Webburza\Sylius\ArticleBundle\Model\ArticleRepositoryInterface;
+use Webburza\Sylius\ArticleBundle\Repository\ArticleRepositoryInterface;
class ArticleController extends ResourceController implements ArticleControllerInterface
{
+ /**
+ * @var ArticleRepositoryInterface
+ */
+ protected $repository;
+
/**
* Show publicly visible articles for the current locale.
*
* @param Request $request
+ *
* @return \Symfony\Component\HttpFoundation\Response
*/
public function indexFrontAction(Request $request)
{
- // Get current locale
- $locale = $this->get('sylius.context.locale')->getCurrentLocale();
-
// Get request configuration
$configuration = $this->requestConfigurationFactory->create($this->metadata, $request);
- /** @var ArticleRepositoryInterface $repository */
- $repository = $this->repository;
+ // Get the category if this is index by category
+ $category = $this->getCategoryFromRequest($request);
// Get a paginator for publicly visible articles for locale
- $articlesPaginator = $repository->getPublicPaginatorForLocale($locale);
- $articlesPaginator->setCurrentPage($this->get('request')->get('page', 1), true, true);
- $articlesPaginator->setMaxPerPage($configuration->getPaginationMaxPerPage());
+ $articles = $this->repository->getPublicPaginatorForLocale($request->getLocale(), $category);
+ $articles->setMaxPerPage($configuration->getPaginationMaxPerPage());
+ $articles->setCurrentPage($request->get('page', 1));
// Get categories for listing
- $categories = $this->get('webburza.repository.article_category')->findBy([
- 'published' => true
+ $categories = $this->get('webburza_article.repository.article_category')->findPublic([
+ 'translation.title' => 'asc'
]);
- // Create the view
- $view = View::create();
-
- // Set template and data
- $view->setTemplate('WebburzaSyliusArticleBundle:Frontend/Article:index.html.twig');
- $view->setData(array(
- 'articles' => $articlesPaginator,
- 'categories' => $categories
- ));
+ $view = View::create($articles);
+
+ if ($configuration->isHtmlRequest()) {
+ $view
+ ->setTemplate('WebburzaSyliusArticleBundle:Frontend/Article:index.html.twig')
+ ->setTemplateVar($this->metadata->getPluralName())
+ ->setData([
+ 'articles' => $articles,
+ 'categories' => $categories,
+ 'category' => $category
+ ]);
+ }
- // Handle view
return $this->viewHandler->handle($configuration, $view);
}
@@ -56,49 +63,60 @@ public function indexFrontAction(Request $request)
*
* @param Request $request
* @param $slug
+ *
* @return \Symfony\Component\HttpFoundation\Response
*/
public function showFrontAction(Request $request, $slug)
{
- // Get current locale
- $locale = $this->get('sylius.context.locale')->getCurrentLocale();
-
// Get request configuration
$configuration = $this->requestConfigurationFactory->create($this->metadata, $request);
- /** @var ArticleRepositoryInterface $repository */
- $repository = $this->repository;
-
// Get a publicly visible article by translated slug
- $article = $repository->findPublicBySlug($slug, $locale);
+ $article = $this->repository->findPublicBySlug($slug, $request->getLocale());
if (!$article) {
throw $this->createNotFoundException();
}
// Get categories for listing
- $categories = $this->get('webburza.repository.article_category')->findBy([
+ $categories = $this->get('webburza_article.repository.article_category')->findBy([
'published' => true
]);
// Get related articles
$relatedArticles =
- $this
- ->get('webburza.repository.article')
- ->getRelatedArticles($article, $locale, 3);
-
- // Create the view
- $view = View::create();
-
- // Set template and data
- $view->setTemplate('WebburzaSyliusArticleBundle:Frontend/Article:show.html.twig');
- $view->setData(array(
- 'article' => $article,
- 'categories' => $categories,
- 'related_articles' => $relatedArticles
- ));
-
- // Handle view
+ $this->get('webburza_article.repository.article')
+ ->getRelatedArticles($article, $request->getLocale(), 4);
+
+ $this->eventDispatcher->dispatch(ResourceActions::SHOW, $configuration, $article);
+
+ $view = View::create($article);
+ if ($configuration->isHtmlRequest()) {
+ $view
+ ->setTemplate('WebburzaSyliusArticleBundle:Frontend/Article:show.html.twig')
+ ->setData([
+ 'article' => $article,
+ 'categories' => $categories,
+ 'relatedArticles' => $relatedArticles
+ ]);
+ }
+
return $this->viewHandler->handle($configuration, $view);
}
+
+ /**
+ * @param Request $request
+ *
+ * @return ArticleCategoryInterface
+ */
+ protected function getCategoryFromRequest(Request $request)
+ {
+ if ($request->get('categorySlug')) {
+ return $this->get('webburza_article.repository.article_category')->findPublicBySlug(
+ $request->get('categorySlug'), $request->getLocale()
+ );
+ }
+
+ return null;
+ }
}
diff --git a/Doctrine/ORM/ArticleCategoryRepository.php b/Doctrine/ORM/ArticleCategoryRepository.php
index ce3b0c9..57d6fd9 100644
--- a/Doctrine/ORM/ArticleCategoryRepository.php
+++ b/Doctrine/ORM/ArticleCategoryRepository.php
@@ -2,12 +2,32 @@
namespace Webburza\Sylius\ArticleBundle\Doctrine\ORM;
+use Doctrine\ORM\QueryBuilder;
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository;
use Webburza\Sylius\ArticleBundle\Model\ArticleCategoryInterface;
-use Webburza\Sylius\ArticleBundle\Model\ArticleCategoryRepositoryInterface;
+use Webburza\Sylius\ArticleBundle\Repository\ArticleCategoryRepositoryInterface;
class ArticleCategoryRepository extends EntityRepository implements ArticleCategoryRepositoryInterface
{
+ /**
+ * @param string $locale
+ *
+ * @return QueryBuilder
+ */
+ public function createListQueryBuilder($locale)
+ {
+ $queryBuilder = $this->createQueryBuilder('o');
+
+ $queryBuilder
+ ->addSelect('translation')
+ ->leftJoin('o.translations', 'translation')
+ ->andWhere('translation.locale = :locale')
+ ->setParameter('locale', $locale)
+ ;
+
+ return $queryBuilder;
+ }
+
/**
* Find a publicly visible article category by a slug, for the provided locale.
*
@@ -35,4 +55,20 @@ public function findPublicBySlug($slug, $locale)
return $category;
}
+
+ /**
+ * @param array $sorting
+ *
+ * @return array
+ */
+ public function findPublic(array $sorting = [])
+ {
+ $queryBuilder = $this->createQueryBuilder('ac');
+ $queryBuilder->leftJoin('ac.translations', 'translation');
+ $queryBuilder->andWhere('ac.published = true');
+
+ $this->applySorting($queryBuilder, $sorting);
+
+ return $queryBuilder->getQuery()->getResult();
+ }
}
diff --git a/Doctrine/ORM/ArticleRepository.php b/Doctrine/ORM/ArticleRepository.php
index 9189625..4ac404b 100644
--- a/Doctrine/ORM/ArticleRepository.php
+++ b/Doctrine/ORM/ArticleRepository.php
@@ -2,13 +2,33 @@
namespace Webburza\Sylius\ArticleBundle\Doctrine\ORM;
+use Doctrine\ORM\QueryBuilder;
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository;
use Webburza\Sylius\ArticleBundle\Model\ArticleCategoryInterface;
use Webburza\Sylius\ArticleBundle\Model\ArticleInterface;
-use Webburza\Sylius\ArticleBundle\Model\ArticleRepositoryInterface;
+use Webburza\Sylius\ArticleBundle\Repository\ArticleRepositoryInterface;
class ArticleRepository extends EntityRepository implements ArticleRepositoryInterface
{
+ /**
+ * @param string $locale
+ *
+ * @return QueryBuilder
+ */
+ public function createListQueryBuilder($locale)
+ {
+ $queryBuilder = $this->createQueryBuilder('o');
+
+ $queryBuilder
+ ->addSelect('translation')
+ ->leftJoin('o.translations', 'translation')
+ ->andWhere('translation.locale = :locale')
+ ->setParameter('locale', $locale)
+ ;
+
+ return $queryBuilder;
+ }
+
/**
* Get publicly visible articles
*
@@ -27,7 +47,7 @@ public function getPublicPaginatorForLocale($locale, ArticleCategoryInterface $c
->andWhere('t.locale = :locale')
->andWhere('a.published = true')
->andWhere('t.active = true')
- ->andWhere('c IS NULL OR c.published = true');
+ ->andWhere('c.id IS NULL OR c.published = true');
$queryBuilder->setParameters([
':locale' => $locale
@@ -64,7 +84,7 @@ public function getRelatedArticles(ArticleInterface $article, $locale, $limit =
->andWhere('t.locale = :locale')
->andWhere('a.published = true')
->andWhere('t.active = true')
- ->andWhere('c IS NULL OR c.published = true')
+ ->andWhere('c.id IS NULL OR c.published = true')
->andWhere('a.id != :currentArticleId');
$queryBuilder->setParameters([
@@ -86,25 +106,26 @@ public function getRelatedArticles(ArticleInterface $article, $locale, $limit =
}
/**
- * Find a publicly visible article by a slug, for the provided locale.
+ * Find an article by a slug, for the provided locale.
*
* @param $slug
* @param $locale
*
- * @return ArticleInterface|null
+ * @return null|ArticleInterface
*/
public function findPublicBySlug($slug, $locale)
{
$queryBuilder = $this->createQueryBuilder('a');
- $queryBuilder->leftJoin('a.translations', 't');
+ $queryBuilder->innerJoin('a.translations', 't');
$queryBuilder->leftJoin('a.category', 'c');
$queryBuilder
->andWhere('t.slug = :slug')
->andWhere('t.locale = :locale')
- ->andWhere('a.published = true')
- ->andWhere('t.active = true')
- ->andWhere('c IS NULL OR c.published = true');
+ ->andWhere('t.active = true');
+
+ $queryBuilder->andWhere('a.published = true');
+ $queryBuilder->andWhere('c.id IS NULL OR c.published = true');
$queryBuilder->setParameters([
':slug' => $slug,
diff --git a/Entity/ArticleImage.php b/Entity/ArticleImage.php
deleted file mode 100644
index e4b8abc..0000000
--- a/Entity/ArticleImage.php
+++ /dev/null
@@ -1,60 +0,0 @@
-article;
- }
-
- /**
- * @param ArticleInterface $article
- * @return ArticleImageInterface
- */
- public function setArticle(ArticleInterface $article)
- {
- $this->article = $article;
-
- return $this;
- }
-
- /**
- * @return string
- */
- public function getName()
- {
- return 'webburza_article_image';
- }
-}
diff --git a/EventListener/FrontendMenuBuilderListener.php b/EventListener/FrontendMenuBuilderListener.php
deleted file mode 100644
index efa264b..0000000
--- a/EventListener/FrontendMenuBuilderListener.php
+++ /dev/null
@@ -1,35 +0,0 @@
-translator = $translator;
- }
-
- public function addFrontendMenuItems(MenuBuilderEvent $event)
- {
- $menu = $event->getMenu();
-
- $menu->addChild('webburza_sylius_articles_front', [
- 'route' => 'webburza_article_frontend_index',
- 'linkAttributes' => [
- 'title' => $this->translator->trans('webburza.sylius.article.index_header')
- ],
- 'labelAttributes' => [
- 'icon' => 'icon-file-text icon-large',
- 'iconOnly' => false
- ],
- ])->setLabel($this->translator->trans('webburza.sylius.article.frontend.articles'));
- }
-}
diff --git a/EventListener/ImageUploadListener.php b/EventListener/ImageUploadListener.php
index fc66b52..3435ad1 100644
--- a/EventListener/ImageUploadListener.php
+++ b/EventListener/ImageUploadListener.php
@@ -8,25 +8,37 @@
class ImageUploadListener
{
+ /**
+ * @var ImageUploaderInterface
+ */
protected $uploader;
+ /**
+ * @param ImageUploaderInterface $uploader
+ */
public function __construct(ImageUploaderInterface $uploader)
{
$this->uploader = $uploader;
}
+ /**
+ * @param GenericEvent $event
+ */
public function uploadArticleImage(GenericEvent $event)
{
/** @var ArticleInterface $subject */
$subject = $event->getSubject();
if (!$subject instanceof ArticleInterface) {
- throw new UnexpectedTypeException($subject, 'Webburza\Sylius\ArticleBundle\Model\ArticleInterface');
+ throw new UnexpectedTypeException(
+ $subject, 'Webburza\Sylius\ArticleBundle\Model\ArticleInterface'
+ );
}
- if ($subject->getImage()->hasFile()) {
+ if ($subject->getImage() && $subject->getImage()->hasFile()) {
$this->uploader->upload($subject->getImage());
- } else {
+ }
+ elseif ($subject->getImage() && !$subject->getImage()->getPath()) {
$subject->clearImage();
}
}
diff --git a/EventListener/MenuBuilderListener.php b/EventListener/MenuBuilderListener.php
index deae091..33018a9 100644
--- a/EventListener/MenuBuilderListener.php
+++ b/EventListener/MenuBuilderListener.php
@@ -1,40 +1,31 @@
translator = $translator;
- }
-
public function addBackendMenuItems(MenuBuilderEvent $event)
{
$menu = $event->getMenu();
- if (isset($menu['content'])) {
- $menu['content']
- ->addChild('webburza_sylius_articles', array(
- 'route' => 'webburza_article_index',
- 'labelAttributes' => array('icon' => 'glyphicon glyphicon-file'),
- ))
- ->setLabel($this->translator->trans('webburza.sylius.article.backend.articles'));
-
- $menu['content']
- ->addChild('webburza_sylius_article_categories', array(
- 'route' => 'webburza_article_category_index',
- 'labelAttributes' => array('icon' => 'glyphicon glyphicon-tags'),
- ))
- ->setLabel($this->translator->trans('webburza.sylius.article_category.backend.article_categories'));
+ // Get or create the parent group
+ if (null == ($contentMenu = $menu->getChild('content'))) {
+ $contentMenu = $menu->addChild('content')->setLabel('webburza_article.ui.content');
}
+
+ // Add 'Articles' menu item
+ $contentMenu->addChild('webburza_articles', ['route' => 'webburza_article_admin_article_index'])
+ ->setLabel('webburza_article.ui.articles')
+ ->setLabelAttribute('icon', 'file');
+
+ // Add 'Article Categories' menu item
+ $contentMenu->addChild('webburza_article_categories', ['route' => 'webburza_article_admin_article_category_index'])
+ ->setLabel('webburza_article.ui.article_categories')
+ ->setLabelAttribute('icon', 'tags');
}
}
diff --git a/EventListener/PublishedListener.php b/EventListener/PublishedListener.php
index c0b46d0..85ccf58 100644
--- a/EventListener/PublishedListener.php
+++ b/EventListener/PublishedListener.php
@@ -1,7 +1,7 @@
getSubject();
if (!$subject instanceof ArticleInterface) {
- throw new UnexpectedTypeException($subject, 'Webburza\Sylius\ArticleBundle\Model\ArticleInterface');
+ throw new UnexpectedTypeException($subject,
+ 'Webburza\Sylius\ArticleBundle\Model\ArticleInterface');
}
if ($subject->isPublished() && $subject->getPublishedAt() == null) {
- $subject->setPublishedAt(new DateTime());
+ $subject->setPublishedAt(new \DateTime());
}
}
}
diff --git a/Form/Extension/ArticleImageRemoveExtension.php b/Form/Extension/ArticleImageRemoveExtension.php
new file mode 100644
index 0000000..7a9208c
--- /dev/null
+++ b/Form/Extension/ArticleImageRemoveExtension.php
@@ -0,0 +1,40 @@
+add('imageRemove', HiddenType::class, [
+ 'mapped' => false,
+ 'allow_extra_fields' => true
+ ]);
+
+ // Remove the Image from the Article if requested
+ $builder->addEventListener(FormEvents::POST_SUBMIT, function(FormEvent $event) {
+ if ($event->getForm()->get('imageRemove')->getData()) {
+ $event->getData()->clearImage();
+ }
+ });
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getExtendedType()
+ {
+ return ArticleType::class;
+ }
+}
diff --git a/Form/Extension/ArticleTranslationActiveExtension.php b/Form/Extension/ArticleTranslationActiveExtension.php
new file mode 100644
index 0000000..5cd2255
--- /dev/null
+++ b/Form/Extension/ArticleTranslationActiveExtension.php
@@ -0,0 +1,47 @@
+availableLocaleCodes = $availableLocaleCodes;
+ }
+
+ /**
+ * Replace 'active' checkbox with a hidden element,
+ * as it is redundant if there is only one active locale.
+ *
+ * @param FormBuilderInterface $builder
+ * @param array $options
+ */
+ public function buildForm(FormBuilderInterface $builder, array $options)
+ {
+ if (count($this->availableLocaleCodes) === 1) {
+ $builder->remove('active');
+ $builder->add('active', HiddenType::class, [ 'data' => "1" ]);
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getExtendedType()
+ {
+ return ArticleTranslationType::class;
+ }
+}
diff --git a/Form/Type/ArticleCategoryChoiceType.php b/Form/Type/ArticleCategoryChoiceType.php
index edb971a..29d25e1 100644
--- a/Form/Type/ArticleCategoryChoiceType.php
+++ b/Form/Type/ArticleCategoryChoiceType.php
@@ -5,11 +5,12 @@
use Sylius\Component\Resource\Repository\RepositoryInterface;
use Symfony\Bridge\Doctrine\Form\DataTransformer\CollectionToArrayTransformer;
use Symfony\Component\Form\AbstractType;
-use Symfony\Component\Form\Extension\Core\ChoiceList\ObjectChoiceList;
+use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
+use Webburza\Sylius\ArticleBundle\Model\ArticleCategoryInterface;
-class ArticleCategoryChoiceType extends AbstractType
+final class ArticleCategoryChoiceType extends AbstractType
{
/**
* @var RepositoryInterface
@@ -41,15 +42,14 @@ public function buildForm(FormBuilderInterface $builder, array $options)
*/
public function configureOptions(OptionsResolver $resolver)
{
- $choiceList = new ObjectChoiceList($this->repository->findAll(), 'title', [], null, 'id');
-
$resolver
->setDefaults([
- 'choice_list' => $choiceList,
- 'label' => 'webburza.sylius.article.label.category',
- 'empty_value' => 'webburza.sylius.article.label.choose_category'
- ])
- ;
+ 'choices' => $this->repository->findAll(),
+ 'choice_label' => function (ArticleCategoryInterface $category) {
+ return $category->getTitle();
+ },
+ 'label' => 'webburza_article.article.label.category'
+ ]);
}
/**
@@ -57,7 +57,7 @@ public function configureOptions(OptionsResolver $resolver)
*/
public function getParent()
{
- return 'choice';
+ return ChoiceType::class;
}
/**
diff --git a/Form/Type/ArticleCategoryTranslationType.php b/Form/Type/ArticleCategoryTranslationType.php
index d197343..889dc46 100644
--- a/Form/Type/ArticleCategoryTranslationType.php
+++ b/Form/Type/ArticleCategoryTranslationType.php
@@ -3,10 +3,10 @@
namespace Webburza\Sylius\ArticleBundle\Form\Type;
use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType;
-use Symfony\Component\Form\Extension\Core\Type;
+use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
-class ArticleCategoryTranslationType extends AbstractResourceType
+final class ArticleCategoryTranslationType extends AbstractResourceType
{
/**
* Build the Article Category Translation form
@@ -16,11 +16,14 @@ class ArticleCategoryTranslationType extends AbstractResourceType
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
- $builder->add('title', 'text', [
- 'label' => 'webburza.sylius.article_category.label.title'
+ $builder->add('title', TextType::class, [
+ 'label' => 'webburza_article.article_category.label.title'
]);
}
+ /**
+ * @return string
+ */
public function getName()
{
return 'webburza_article_category_translation';
diff --git a/Form/Type/ArticleCategoryType.php b/Form/Type/ArticleCategoryType.php
index 2298c16..9d87742 100644
--- a/Form/Type/ArticleCategoryType.php
+++ b/Form/Type/ArticleCategoryType.php
@@ -3,29 +3,31 @@
namespace Webburza\Sylius\ArticleBundle\Form\Type;
use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType;
-use Symfony\Component\Form\Extension\Core\Type;
+use Sylius\Bundle\ResourceBundle\Form\Type\ResourceTranslationsType;
+use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\FormBuilderInterface;
-class ArticleCategoryType extends AbstractResourceType
+final class ArticleCategoryType extends AbstractResourceType
{
/**
- * Build the Article Category form
- *
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
- $builder->add('translations', 'sylius_translations', [
- 'type' => 'webburza_article_category_translation',
- 'label' => 'webburza.sylius.article_category.translations'
+ $builder->add('translations', ResourceTranslationsType::class, [
+ 'entry_type' => ArticleCategoryTranslationType::class,
+ 'label' => 'webburza_article.article_category.translations'
]);
- $builder->add('published', 'checkbox', [
- 'label' => 'webburza.sylius.article_category.label.published'
+ $builder->add('published', CheckboxType::class, [
+ 'label' => 'webburza_article.article_category.label.published'
]);
}
+ /**
+ * @return string
+ */
public function getName()
{
return 'webburza_article_category';
diff --git a/Form/Type/ArticleImageType.php b/Form/Type/ArticleImageType.php
index 015f245..dcf3ef7 100644
--- a/Form/Type/ArticleImageType.php
+++ b/Form/Type/ArticleImageType.php
@@ -3,18 +3,18 @@
namespace Webburza\Sylius\ArticleBundle\Form\Type;
use Sylius\Bundle\CoreBundle\Form\Type\ImageType;
+use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\FormBuilderInterface;
-class ArticleImageType extends ImageType
+final class ArticleImageType extends ImageType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
- $builder->add('file', 'file', [
- 'label' => 'webburza.sylius.article.label.file',
- 'property_path' => 'file'
+ $builder->add('file', FileType::class, [
+ 'label' => 'webburza.sylius.article.label.file'
]);
}
diff --git a/Form/Type/ArticleTranslationType.php b/Form/Type/ArticleTranslationType.php
index 5f71879..da94a48 100644
--- a/Form/Type/ArticleTranslationType.php
+++ b/Form/Type/ArticleTranslationType.php
@@ -3,10 +3,12 @@
namespace Webburza\Sylius\ArticleBundle\Form\Type;
use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType;
-use Symfony\Component\Form\Extension\Core\Type;
+use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
+use Symfony\Component\Form\Extension\Core\Type\TextareaType;
+use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
-class ArticleTranslationType extends AbstractResourceType
+final class ArticleTranslationType extends AbstractResourceType
{
/**
* Build the Article form
@@ -16,32 +18,36 @@ class ArticleTranslationType extends AbstractResourceType
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
- $builder->add('title', 'text', [
- 'label' => 'webburza.sylius.article.label.title'
+ $builder->add('title', TextType::class, [
+ 'label' => 'webburza_article.article.label.title'
]);
- $builder->add('lead', 'textarea', [
- 'label' => 'webburza.sylius.article.label.lead',
- 'attr' => ['rows' => 4]
+ $builder->add('lead', TextareaType::class, [
+ 'label' => 'webburza_article.article.label.lead',
+ 'attr' => ['rows' => 4],
+ 'required' => false
]);
- $builder->add('content', 'textarea', [
- 'label' => 'webburza.sylius.article.label.content',
- 'attr' => ['class' => 'ckeditor']
+ $builder->add('content', TextareaType::class, [
+ 'label' => 'webburza_article.article.label.content',
+ 'attr' => ['class' => 'ckeditor']
]);
- $builder->add('active', 'checkbox', [
- 'label' => 'webburza.sylius.article.label.active'
+ $builder->add('metaKeywords', TextareaType::class, [
+ 'label' => 'webburza_article.article.label.meta_keywords',
+ 'attr' => ['rows' => 2],
+ 'required' => false
]);
- $builder->add('metaKeywords', 'textarea', [
- 'label' => 'webburza.sylius.article.label.meta_keywords',
- 'attr' => ['rows' => 2]
+ $builder->add('metaDescription', TextareaType::class, [
+ 'label' => 'webburza_article.article.label.meta_description',
+ 'attr' => ['rows' => 2],
+ 'required' => false
]);
- $builder->add('metaDescription', 'textarea', [
- 'label' => 'webburza.sylius.article.label.meta_description',
- 'attr' => ['rows' => 2]
+ $builder->add('active', CheckboxType::class, [
+ 'label' => 'webburza_article.article.label.active',
+ 'data' => true
]);
}
diff --git a/Form/Type/ArticleType.php b/Form/Type/ArticleType.php
index cd0467d..8e288e2 100644
--- a/Form/Type/ArticleType.php
+++ b/Form/Type/ArticleType.php
@@ -3,61 +3,65 @@
namespace Webburza\Sylius\ArticleBundle\Form\Type;
use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType;
-use Symfony\Component\Form\Extension\Core\Type;
+use Sylius\Bundle\ResourceBundle\Form\Type\ResourceTranslationsType;
+use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
+use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\Valid;
-class ArticleType extends AbstractResourceType
+final class ArticleType extends AbstractResourceType
{
/**
- * Build the Article form
- *
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
- $builder->add('translations', 'sylius_translations', [
- 'type' => 'webburza_article_translation',
- 'label' => 'webburza.sylius.article.translations',
+ $builder->add('translations', ResourceTranslationsType::class, [
+ 'entry_type' => ArticleTranslationType::class,
+ 'label' => 'webburza_article.article.translations',
'constraints' => [
new Valid()
]
]);
- $builder->add('image', 'webburza_article_image', [
- 'label' => 'webburza.sylius.article.label.cover_image'
+ $builder->add('image', ArticleImageType::class, [
+ 'label' => 'webburza_article.article.label.cover_image'
]);
- $builder->add('category', 'webburza_article_category_choice', [
- 'label' => 'webburza.sylius.article.label.category'
+ $builder->add('category', ArticleCategoryChoiceType::class, [
+ 'label' => 'webburza_article.article.label.category',
+ 'required' => false
]);
- $builder->add('products', 'webburza_article_product_choice', [
- 'label' => 'webburza.sylius.article.label.products',
- 'attr' => [
+ $builder->add('products', ProductChoiceType::class, [
+ 'label' => 'webburza_article.article.label.products',
+ 'attr' => [
'size' => 10
],
- 'multiple' => true
+ 'multiple' => true,
+ 'required' => false
]);
- $builder->add('publishedAt', 'datetime', [
- 'label' => 'webburza.sylius.article.label.published_at',
- 'required' => false,
- 'date_format' => 'y-M-d',
- 'date_widget' => 'choice',
- 'time_widget' => 'text'
+ $builder->add('featured', CheckboxType::class, [
+ 'label' => 'webburza_article.article.label.featured'
]);
- $builder->add('published', 'checkbox', [
- 'label' => 'webburza.sylius.article.label.published'
+ $builder->add('published', CheckboxType::class, [
+ 'label' => 'webburza_article.article.label.published'
]);
- $builder->add('featured', 'checkbox', [
- 'label' => 'webburza.sylius.article.label.featured'
+ $builder->add('publishedAt', DateTimeType::class, [
+ 'label' => 'webburza_article.article.label.published_at',
+ 'date_widget' => 'single_text',
+ 'time_widget' => 'single_text',
+ 'required' => false
]);
}
+ /**
+ * @return string
+ */
public function getName()
{
return 'webburza_article';
diff --git a/Form/Type/ProductChoiceType.php b/Form/Type/ProductChoiceType.php
index 0aea92b..ed06ce2 100644
--- a/Form/Type/ProductChoiceType.php
+++ b/Form/Type/ProductChoiceType.php
@@ -2,14 +2,15 @@
namespace Webburza\Sylius\ArticleBundle\Form\Type;
+use Sylius\Component\Product\Model\ProductInterface;
use Sylius\Component\Resource\Repository\RepositoryInterface;
use Symfony\Bridge\Doctrine\Form\DataTransformer\CollectionToArrayTransformer;
use Symfony\Component\Form\AbstractType;
-use Symfony\Component\Form\Extension\Core\ChoiceList\ObjectChoiceList;
+use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
-class ProductChoiceType extends AbstractType
+final class ProductChoiceType extends AbstractType
{
/**
* @var RepositoryInterface
@@ -41,15 +42,14 @@ public function buildForm(FormBuilderInterface $builder, array $options)
*/
public function configureOptions(OptionsResolver $resolver)
{
- $choiceList = new ObjectChoiceList($this->repository->findAll(), 'name', [], null, 'id');
-
$resolver
->setDefaults([
- 'choice_list' => $choiceList,
- 'label' => 'webburza.sylius.article.label.products',
- 'empty_value' => 'webburza.sylius.article.label.choose_products'
- ])
- ;
+ 'choices' => $this->repository->findAll(),
+ 'choice_label' => function(ProductInterface $product) {
+ return $product->getName();
+ },
+ 'label' => 'webburza_article.article.label.products'
+ ]);
}
/**
@@ -57,7 +57,7 @@ public function configureOptions(OptionsResolver $resolver)
*/
public function getParent()
{
- return 'choice';
+ return ChoiceType::class;
}
/**
diff --git a/Entity/Article.php b/Model/Article.php
similarity index 61%
rename from Entity/Article.php
rename to Model/Article.php
index 4d7652b..b1971aa 100644
--- a/Entity/Article.php
+++ b/Model/Article.php
@@ -1,101 +1,57 @@
translate()->getTitle();
+ return $this->getTranslation()->getTitle();
}
/**
@@ -129,7 +85,7 @@ public function getTitle()
*/
public function getSlug()
{
- return $this->translate()->getSlug();
+ return $this->getTranslation()->getSlug();
}
/**
@@ -137,7 +93,7 @@ public function getSlug()
*/
public function getLead()
{
- return $this->translate()->getLead();
+ return $this->getTranslation()->getLead();
}
/**
@@ -145,7 +101,7 @@ public function getLead()
*/
public function getContent()
{
- return $this->translate()->getContent();
+ return $this->getTranslation()->getContent();
}
/**
@@ -158,6 +114,7 @@ public function isPublished()
/**
* @param boolean $published
+ *
* @return ArticleInterface
*/
public function setPublished($published)
@@ -177,6 +134,7 @@ public function isFeatured()
/**
* @param boolean $featured
+ *
* @return ArticleInterface
*/
public function setFeatured($featured)
@@ -196,53 +154,16 @@ public function getPublishedAt()
/**
* @param \DateTime $publishedAt
+ *
* @return ArticleInterface
*/
- public function setPublishedAt($publishedAt)
+ public function setPublishedAt(\DateTime $publishedAt = null)
{
$this->publishedAt = $publishedAt;
return $this;
}
- /**
- * @return \DateTime
- */
- public function getCreatedAt()
- {
- return $this->createdAt;
- }
-
- /**
- * @param \DateTime $createdAt
- * @return ArticleInterface
- */
- public function setCreatedAt($createdAt)
- {
- $this->createdAt = $createdAt;
-
- return $this;
- }
-
- /**
- * @return \DateTime
- */
- public function getUpdatedAt()
- {
- return $this->updatedAt;
- }
-
- /**
- * @param \DateTime $updatedAt
- * @return ArticleInterface
- */
- public function setUpdatedAt($updatedAt)
- {
- $this->updatedAt = $updatedAt;
-
- return $this;
- }
-
/**
* @return ArticleImageInterface
*/
@@ -253,12 +174,12 @@ public function getImage()
/**
* @param ArticleImageInterface $image
+ *
* @return ArticleInterface
*/
public function setImage(ArticleImageInterface $image)
{
$this->image = $image;
- $image->setArticle($this);
return $this;
}
@@ -280,7 +201,7 @@ public function clearImage()
*/
public function getMetaKeywords()
{
- return $this->translate()->getMetaKeywords();
+ return $this->getTranslation()->getMetaKeywords();
}
/**
@@ -288,7 +209,7 @@ public function getMetaKeywords()
*/
public function getMetaDescription()
{
- return $this->translate()->getMetaDescription();
+ return $this->getTranslation()->getMetaDescription();
}
/**
@@ -301,6 +222,7 @@ public function getCategory()
/**
* @param ArticleCategoryInterface $category
+ *
* @return ArticleInterface
*/
public function setCategory(ArticleCategoryInterface $category = null)
@@ -320,6 +242,7 @@ public function getProducts()
/**
* @param ArrayCollection $products
+ *
* @return ArticleInterface
*/
public function setProducts(ArrayCollection $products)
@@ -331,6 +254,7 @@ public function setProducts(ArrayCollection $products)
/**
* @param ProductInterface $product
+ *
* @return ArticleInterface
*/
public function addProduct(ProductInterface $product)
@@ -342,6 +266,7 @@ public function addProduct(ProductInterface $product)
/**
* @param ProductInterface $product
+ *
* @return ArticleInterface
*/
public function removeProduct(ProductInterface $product)
@@ -350,4 +275,12 @@ public function removeProduct(ProductInterface $product)
return $this;
}
+
+ /**
+ * @return ArticleTranslationInterface
+ */
+ public function createTranslation()
+ {
+ return new ArticleTranslation();
+ }
}
diff --git a/Entity/ArticleCategory.php b/Model/ArticleCategory.php
similarity index 51%
rename from Entity/ArticleCategory.php
rename to Model/ArticleCategory.php
index 1a73dd3..0afa706 100644
--- a/Entity/ArticleCategory.php
+++ b/Model/ArticleCategory.php
@@ -1,63 +1,32 @@
articles = new ArrayCollection();
$this->initializeTranslationsCollection();
+
+ $this->articles = new ArrayCollection();
}
/**
@@ -83,7 +53,7 @@ public function getId()
*/
public function getTitle()
{
- return $this->translate()->getTitle();
+ return $this->getTranslation()->getTitle();
}
/**
@@ -91,45 +61,7 @@ public function getTitle()
*/
public function getSlug()
{
- return $this->translate()->getSlug();
- }
-
- /**
- * @return \DateTime
- */
- public function getCreatedAt()
- {
- return $this->createdAt;
- }
-
- /**
- * @param \DateTime $createdAt
- * @return ArticleCategoryInterface
- */
- public function setCreatedAt($createdAt)
- {
- $this->createdAt = $createdAt;
-
- return $this;
- }
-
- /**
- * @return \DateTime
- */
- public function getUpdatedAt()
- {
- return $this->updatedAt;
- }
-
- /**
- * @param \DateTime $updatedAt
- * @return ArticleCategoryInterface
- */
- public function setUpdatedAt($updatedAt)
- {
- $this->updatedAt = $updatedAt;
-
- return $this;
+ return $this->getTranslation()->getSlug();
}
/**
@@ -142,6 +74,7 @@ public function isPublished()
/**
* @param boolean $published
+ *
* @return ArticleCategoryInterface
*/
public function setPublished($published)
@@ -161,6 +94,7 @@ public function getArticles()
/**
* @param $articles
+ *
* @return ArticleCategoryInterface
*/
public function setArticles($articles)
@@ -172,6 +106,7 @@ public function setArticles($articles)
/**
* @param ArticleInterface $article
+ *
* @return ArticleCategoryInterface
*/
public function addArticle(ArticleInterface $article)
@@ -180,4 +115,12 @@ public function addArticle(ArticleInterface $article)
return $this;
}
+
+ /**
+ * @return ArticleCategoryTranslationInterface
+ */
+ public function createTranslation()
+ {
+ return new ArticleCategoryTranslation();
+ }
}
diff --git a/Model/ArticleCategoryControllerInterface.php b/Model/ArticleCategoryControllerInterface.php
index 2a95089..f888d08 100644
--- a/Model/ArticleCategoryControllerInterface.php
+++ b/Model/ArticleCategoryControllerInterface.php
@@ -12,6 +12,7 @@ interface ArticleCategoryControllerInterface extends ContainerAwareInterface
*
* @param Request $request
* @param $slug
+ *
* @return \Symfony\Component\HttpFoundation\Response
*/
public function showFrontAction(Request $request, $slug);
diff --git a/Model/ArticleCategoryInterface.php b/Model/ArticleCategoryInterface.php
index f62a8ed..3cfbb1b 100644
--- a/Model/ArticleCategoryInterface.php
+++ b/Model/ArticleCategoryInterface.php
@@ -24,9 +24,10 @@ public function getCreatedAt();
/**
* @param \DateTime $createdAt
+ *
* @return ArticleCategoryInterface
*/
- public function setCreatedAt($createdAt);
+ public function setCreatedAt(\DateTime $createdAt);
/**
* @return \DateTime
@@ -35,9 +36,10 @@ public function getUpdatedAt();
/**
* @param \DateTime $updatedAt
+ *
* @return ArticleCategoryInterface
*/
- public function setUpdatedAt($updatedAt);
+ public function setUpdatedAt(\DateTime $updatedAt);
/**
* @return boolean
@@ -46,6 +48,7 @@ public function isPublished();
/**
* @param boolean $published
+ *
* @return ArticleCategoryInterface
*/
public function setPublished($published);
@@ -57,13 +60,20 @@ public function getArticles();
/**
* @param $articles
+ *
* @return ArticleCategoryInterface
*/
public function setArticles($articles);
/**
* @param ArticleInterface $article
+ *
* @return ArticleCategoryInterface
*/
public function addArticle(ArticleInterface $article);
+
+ /**
+ * @return ArticleCategoryTranslationInterface
+ */
+ public function createTranslation();
}
diff --git a/Model/ArticleCategoryRepositoryInterface.php b/Model/ArticleCategoryRepositoryInterface.php
deleted file mode 100644
index 1b52cb7..0000000
--- a/Model/ArticleCategoryRepositoryInterface.php
+++ /dev/null
@@ -1,18 +0,0 @@
-](http://i.imgur.com/lfP83VR.jpg)
-[ ](http://i.imgur.com/H2L9ziy.jpg)
-[ ](http://i.imgur.com/zjFYdyN.png)
+[ ](http://i.imgur.com/nNT1UGR.png)
+[ ](http://i.imgur.com/kVjHfIj.png)
+[ ](http://i.imgur.com/swCDPI2.png)
---
@@ -35,18 +35,18 @@ group articles into categories, and the ability to set related products for arti
```yaml
imports:
- - { resource: @WebburzaSyliusArticleBundle/Resources/config/config.yml }
+ - { resource: "@WebburzaSyliusArticleBundle/Resources/config/config.yml" }
```
4. register routes in `app/config/routing.yml`
```yaml
- webburza_sylius_article_bundle:
+ webburza_article:
resource: "@WebburzaSyliusArticleBundle/Resources/config/routing.yml"
-
- webburza_sylius_article_bundle_front:
+
+ webburza_article_front:
resource: "@WebburzaSyliusArticleBundle/Resources/config/routingFront.yml"
- prefix: /articles
+ prefix: /articles
```
As you can see, there are two groups of routes, the main resource (administration) routes,
@@ -54,16 +54,18 @@ group articles into categories, and the ability to set related products for arti
set the prefix for the routes here, changing it to `/blog`, or `/news`.
5. The bundle should now be fully integrated, but it still requires
-database tables to be created and RBAC permissions set. To ease this
-process, after you've integrated the bundle you can run the
-following command:
+database tables to be created. For this, we recommend using migrations.
```bash
- $ app/console webburza:sylius-article-bundle:install
+ $ bin/console doctrine:migrations:diff
+ $ bin/console doctrine:migrations:migrate
+ ```
+
+ Or if you don't use migrations, you can update the database schema directly.
+
+ ```bash
+ $ bin/console doctrine:schema:update
```
-
- This will create all the required database tables, prefixed with `webburza_`,
-and all the RBAC permissions, under the existing 'content' node.
## Configuration
@@ -113,4 +115,4 @@ This bundle is available under the [MIT license](LICENSE).
## To-do
-- Tests
+- Automated tests
diff --git a/Repository/ArticleCategoryRepositoryInterface.php b/Repository/ArticleCategoryRepositoryInterface.php
new file mode 100644
index 0000000..8aadee1
--- /dev/null
+++ b/Repository/ArticleCategoryRepositoryInterface.php
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Resources/config/doctrine/ArticleCategory.orm.xml b/Resources/config/doctrine/ArticleCategory.orm.xml
new file mode 100644
index 0000000..678a04f
--- /dev/null
+++ b/Resources/config/doctrine/ArticleCategory.orm.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Resources/config/doctrine/ArticleCategoryTranslation.orm.xml b/Resources/config/doctrine/ArticleCategoryTranslation.orm.xml
new file mode 100644
index 0000000..76f4207
--- /dev/null
+++ b/Resources/config/doctrine/ArticleCategoryTranslation.orm.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Resources/config/doctrine/ArticleImage.orm.xml b/Resources/config/doctrine/ArticleImage.orm.xml
new file mode 100644
index 0000000..a733be0
--- /dev/null
+++ b/Resources/config/doctrine/ArticleImage.orm.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
diff --git a/Resources/config/doctrine/ArticleTranslation.orm.xml b/Resources/config/doctrine/ArticleTranslation.orm.xml
new file mode 100644
index 0000000..b157bd3
--- /dev/null
+++ b/Resources/config/doctrine/ArticleTranslation.orm.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Resources/config/grids.yml b/Resources/config/grids.yml
new file mode 100644
index 0000000..58e8114
--- /dev/null
+++ b/Resources/config/grids.yml
@@ -0,0 +1,3 @@
+imports:
+ - { resource: "grids/article.yml" }
+ - { resource: "grids/articleCategory.yml" }
diff --git a/Resources/config/grids/article.yml b/Resources/config/grids/article.yml
new file mode 100644
index 0000000..662e14d
--- /dev/null
+++ b/Resources/config/grids/article.yml
@@ -0,0 +1,74 @@
+sylius_grid:
+ grids:
+ webburza_article_admin:
+ driver:
+ name: doctrine/orm
+ options:
+ class: "%webburza_article.model.article.class%"
+ repository:
+ method: createListQueryBuilder
+ arguments: ["%locale%"]
+ fields:
+ id:
+ type: string
+ label: webburza_article.article.label.id
+ sortable: ~
+ title:
+ type: twig
+ label: webburza_article.article.label.title
+ sortable: translation.title
+ path: .
+ options:
+ template: "WebburzaSyliusArticleBundle:Backend/Article:_gridTitle.html.twig"
+ coverImage:
+ type: twig
+ label: webburza_article.article.label.cover_image
+ path: .
+ options:
+ template: "WebburzaSyliusArticleBundle:Backend/Article:_gridImage.html.twig"
+ published:
+ type: twig
+ label: webburza_article.article_category.label.published
+ sortable: ~
+ options:
+ template: SyliusUiBundle:Grid/Field:yesNo.html.twig
+ publishedAt:
+ type: datetime
+ label: webburza_article.article.label.published_at
+ sortable: ~
+ options:
+ format: 'd-m-Y H:i'
+ createdAt:
+ type: datetime
+ label: webburza_article.article.label.created_at
+ sortable: ~
+ options:
+ format: 'd-m-Y H:i'
+ updatedAt:
+ type: datetime
+ label: webburza_article.article.label.updated_at
+ sortable: ~
+ options:
+ format: 'd-m-Y H:i'
+ actions:
+ main:
+ create:
+ type: create
+ item:
+ update:
+ type: update
+ delete:
+ type: delete
+ filters:
+ text:
+ type: string
+ label: webburza_article.article.label.title
+ options:
+ fields: [translation.title, translation.lead, translation.content]
+ published:
+ type: boolean
+ label: webburza_article.article.label.published
+ sorting:
+ published: asc
+ publishedAt: desc
+ createdAt: desc
diff --git a/Resources/config/grids/articleCategory.yml b/Resources/config/grids/articleCategory.yml
new file mode 100644
index 0000000..5a090da
--- /dev/null
+++ b/Resources/config/grids/articleCategory.yml
@@ -0,0 +1,57 @@
+sylius_grid:
+ grids:
+ webburza_article_category_admin:
+ driver:
+ name: doctrine/orm
+ options:
+ class: "%webburza_article.model.article_category.class%"
+ repository:
+ method: createListQueryBuilder
+ arguments: ["%locale%"]
+ sorting:
+ createdAt: desc
+ fields:
+ id:
+ type: string
+ label: webburza_article.article_category.label.id
+ sortable: ~
+ title:
+ type: string
+ label: webburza_article.article_category.label.title
+ sortable: translation.title
+ published:
+ type: twig
+ label: webburza_article.article_category.label.published
+ sortable: ~
+ options:
+ template: SyliusUiBundle:Grid/Field:yesNo.html.twig
+ createdAt:
+ type: datetime
+ label: webburza_article.article_category.label.created_at
+ sortable: ~
+ options:
+ format: 'd-m-Y H:i'
+ updatedAt:
+ type: datetime
+ label: webburza_article.article_category.label.updated_at
+ sortable: ~
+ options:
+ format: 'd-m-Y H:i'
+ actions:
+ main:
+ create:
+ type: create
+ item:
+ update:
+ type: update
+ delete:
+ type: delete
+ filters:
+ title:
+ type: string
+ label: webburza_article.article_category.label.title
+ options:
+ fields: [translation.title]
+ published:
+ type: boolean
+ label: webburza_article.article_category.label.published
diff --git a/Resources/config/parameters.yml b/Resources/config/parameters.yml
new file mode 100644
index 0000000..c8b9389
--- /dev/null
+++ b/Resources/config/parameters.yml
@@ -0,0 +1,32 @@
+parameters:
+ # Models
+ webburza_article.model.article.class: Webburza\Sylius\ArticleBundle\Model\Article
+ webburza_article.model.article_translation.class: Webburza\Sylius\ArticleBundle\Model\ArticleTranslation
+ webburza_article.model.article_category.class: Webburza\Sylius\ArticleBundle\Model\ArticleCategory
+ webburza_article.model.article_category_translation.class: Webburza\Sylius\ArticleBundle\Model\ArticleCategoryTranslation
+ webburza_article.model.article_image.class: Webburza\Sylius\ArticleBundle\Model\ArticleImage
+
+ # Controllers
+ webburza_article.controller.article.class: Webburza\Sylius\ArticleBundle\Controller\ArticleController
+ webburza_article.controller.article_category.class: Webburza\Sylius\ArticleBundle\Controller\ArticleCategoryController
+
+ # Repositories
+ webburza_article.repository.article.class: Webburza\Sylius\ArticleBundle\Doctrine\ORM\ArticleRepository
+
+ # Listeners
+ webburza_article.listener.menu_builder.class: Webburza\Sylius\ArticleBundle\EventListener\MenuBuilderListener
+ webburza_article.listener.published.class: Webburza\Sylius\ArticleBundle\EventListener\PublishedListener
+ webburza_article.listener.image_upload.class: Webburza\Sylius\ArticleBundle\EventListener\ImageUploadListener
+
+ # Form Types
+ webburza_article.form.type.article.class: Webburza\Sylius\ArticleBundle\Form\Type\ArticleType
+ webburza_article.form.type.article_translation.class: Webburza\Sylius\ArticleBundle\Form\Type\ArticleTranslationType
+ webburza_article.form.type.article_category.class: Webburza\Sylius\ArticleBundle\Form\Type\ArticleCategoryType
+ webburza_article.form.type.article_category_translation.class: Webburza\Sylius\ArticleBundle\Form\Type\ArticleCategoryTranslationType
+ webburza_article.form.type.article_image.class: Webburza\Sylius\ArticleBundle\Form\Type\ArticleImageType
+ webburza_article.form.type.article_category_choice.class: Webburza\Sylius\ArticleBundle\Form\Type\ArticleCategoryChoiceType
+ webburza_article.form.type.product_choice.class: Webburza\Sylius\ArticleBundle\Form\Type\ProductChoiceType
+
+ # Form Extensions
+ webburza_article.form.extension.article_translation_active.class: Webburza\Sylius\ArticleBundle\Form\Extension\ArticleTranslationActiveExtension
+ webburza_article.form.extension.article_image_remove.class: Webburza\Sylius\ArticleBundle\Form\Extension\ArticleImageRemoveExtension
diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml
index 85b8b0c..dbc3ea8 100644
--- a/Resources/config/routing.yml
+++ b/Resources/config/routing.yml
@@ -2,55 +2,41 @@
# BACKEND
# ------------------------------------------------------------------------------
-webburza_article_category:
+webburza_article:
resource: |
- alias: webburza.article_category
- templates: WebburzaSyliusArticleBundle:Backend/Category
- except: ['index']
+ alias: webburza_article.article
+ templates: SyliusAdminBundle:Crud
+ except: ['show']
+ redirect: update
+ grid: webburza_article_admin
+ section: admin
+ vars:
+ all:
+ header: webburza_article.ui.articles
+ subheader: webburza_article.ui.manage_articles
+ templates:
+ form: WebburzaSyliusArticleBundle:Backend/Article:_form.html.twig
type: sylius.resource
- prefix: /administration
-
-webburza_article_category_index:
- path: /administration/article-categories/
- methods: [GET]
+ prefix: /admin
defaults:
- _controller: webburza.controller.article_category:indexAction
- _sylius:
- template: WebburzaSyliusArticleBundle:Backend/Category:index.html.twig
- sortable: true
- paginate: 10
+ browseUrl: '%webburza.sylius.article_bundle.file_browser.browse_url%'
+ uploadUrl: '%webburza.sylius.article_bundle.file_browser.upload_url%'
-webburza_article:
+webburza_article_category:
resource: |
- alias: webburza.article
- templates: WebburzaSyliusArticleBundle:Backend/Article
- except: ['index']
+ alias: webburza_article.article_category
+ templates: SyliusAdminBundle:Crud
+ except: ['show']
+ redirect: update
+ grid: webburza_article_category_admin
+ section: admin
+ vars:
+ all:
+ header: webburza_article.ui.article_categories
+ subheader: webburza_article.ui.manage_article_categories
+ templates:
+ form: WebburzaSyliusArticleBundle:Backend/ArticleCategory:_form.html.twig
+ index:
+ icon: tags
type: sylius.resource
- prefix: /administration
- defaults:
- browse_url: %webburza.sylius.article_bundle.file_browser.browse_url%
- upload_url: %webburza.sylius.article_bundle.file_browser.upload_url%
-
-webburza_article_index:
- path: /administration/articles/
- methods: [GET]
- defaults:
- _controller: webburza.controller.article:indexAction
- _sylius:
- template: WebburzaSyliusArticleBundle:Backend/Article:index.html.twig
- sortable: true
- paginate: 10
- sorting:
- published: asc
- publishedAt: desc
- createdAt: desc
-
-webburza_article_image_delete:
- path: /administration/article-image/{id}
- methods: [DELETE]
- defaults:
- _controller: webburza.controller.article_image:deleteAction
- _sylius:
- redirect:
- route: webburza_article_show
- parameters: { id: $articleId }
+ prefix: /admin
diff --git a/Resources/config/routingFront.yml b/Resources/config/routingFront.yml
index cc106b5..e8b3124 100644
--- a/Resources/config/routingFront.yml
+++ b/Resources/config/routingFront.yml
@@ -6,16 +6,16 @@ webburza_article_frontend_index:
path: /
methods: [GET]
defaults:
- _controller: webburza.controller.article:indexFrontAction
+ _controller: webburza_article.controller.article:indexFrontAction
webburza_article_frontend_show:
path: /{slug}/
methods: [GET]
defaults:
- _controller: webburza.controller.article:showFrontAction
+ _controller: webburza_article.controller.article:showFrontAction
-webburza_article_category_frontend_show:
- path: /category/{slug}/
+webburza_article_frontend_index_by_category:
+ path: /category/{categorySlug}/
methods: [GET]
defaults:
- _controller: webburza.controller.article_category:showFrontAction
+ _controller: webburza_article.controller.article:indexFrontAction
diff --git a/Resources/config/services.yml b/Resources/config/services.yml
index 3444efd..920a517 100644
--- a/Resources/config/services.yml
+++ b/Resources/config/services.yml
@@ -1,44 +1,80 @@
services:
- webburza.sylius.article.listener.menu_builder:
- class: Webburza\Sylius\ArticleBundle\EventListener\MenuBuilderListener
- arguments: [@translator]
+ webburza_article.listener.menu_builder:
+ class: '%webburza_article.listener.menu_builder.class%'
tags:
- - { name: kernel.event_listener, event: sylius.menu_builder.backend.main, method: addBackendMenuItems }
- - { name: kernel.event_listener, event: sylius.menu_builder.backend.sidebar, method: addBackendMenuItems }
+ - { name: kernel.event_listener, event: sylius.menu.admin.main, method: addBackendMenuItems }
- webburza.sylius.article.listener.front_menu_builder:
- class: Webburza\Sylius\ArticleBundle\EventListener\FrontendMenuBuilderListener
- arguments: [@translator]
+ webburza_article.listener.published:
+ class: '%webburza_article.listener.published.class%'
tags:
- - { name: kernel.event_listener, event: sylius.menu_builder.frontend.main, method: addFrontendMenuItems }
+ - { name: kernel.event_listener, event: webburza_article.article.pre_create, method: setPublishedAt }
+ - { name: kernel.event_listener, event: webburza_article.article.pre_update, method: setPublishedAt }
- webburza.sylius.article.listener.published:
- class: Webburza\Sylius\ArticleBundle\EventListener\PublishedListener
+ webburza_article.listener.image_upload:
+ class: '%webburza_article.listener.image_upload.class%'
+ arguments:
+ - '@sylius.image_uploader'
tags:
- - { name: kernel.event_listener, event: webburza.article.pre_create, method: setPublishedAt }
- - { name: kernel.event_listener, event: webburza.article.pre_update, method: setPublishedAt }
+ - { name: kernel.event_listener, event: webburza_article.article.pre_create, method: uploadArticleImage }
+ - { name: kernel.event_listener, event: webburza_article.article.pre_update, method: uploadArticleImage }
- webburza.sylius.article.listener.image_upload:
- class: Webburza\Sylius\ArticleBundle\EventListener\ImageUploadListener
- arguments: [@sylius.image_uploader]
+ webburza_article.form.type.article_category_choice:
+ class: '%webburza_article.form.type.article_category_choice.class%'
+ arguments:
+ - '@webburza_article.repository.article_category'
tags:
- - { name: kernel.event_listener, event: webburza.article.pre_create, method: uploadArticleImage }
- - { name: kernel.event_listener, event: webburza.article.pre_update, method: uploadArticleImage }
+ - { name: form.type, alias: webburza_article_category_choice }
+
+ webburza_article.form.type.product_choice:
+ class: '%webburza_article.form.type.product_choice.class%'
+ arguments:
+ - '@sylius.repository.product'
+ tags:
+ - { name: form.type, alias: webburza_article_product_choice }
- webburza.sylius.article.form.type.article_image:
- class: Webburza\Sylius\ArticleBundle\Form\Type\ArticleImageType
+ webburza_article.form.type.article_image:
+ class: '%webburza_article.form.type.article_image.class%'
+ arguments:
+ - '%webburza_article.model.article_image.class%'
tags:
- { name: form.type, alias: webburza_article_image }
- arguments: [Webburza\Sylius\ArticleBundle\Entity\ArticleImage]
- webburza.sylius.article.form.type.article_category_choice:
- class: Webburza\Sylius\ArticleBundle\Form\Type\ArticleCategoryChoiceType
+ webburza_article.form.type.article:
+ class: '%webburza_article.form.type.article.class%'
+ arguments:
+ - '%webburza_article.model.article.class%'
tags:
- - { name: form.type, alias: webburza_article_category_choice }
- arguments: [@webburza.repository.article_category]
+ - { name: form.type, alias: webburza_article }
- webburza.sylius.article.form.type.product_choice:
- class: Webburza\Sylius\ArticleBundle\Form\Type\ProductChoiceType
+ webburza_article.form.type.article_translation:
+ class: '%webburza_article.form.type.article_translation.class%'
+ arguments:
+ - '%webburza_article.model.article_translation.class%'
tags:
- - { name: form.type, alias: webburza_article_product_choice }
- arguments: [@sylius.repository.product]
+ - { name: form.type, alias: webburza_article_translation }
+
+ webburza_article.form.type.article_category:
+ class: '%webburza_article.form.type.article_category.class%'
+ arguments:
+ - '%webburza_article.model.article_category.class%'
+ tags:
+ - { name: form.type, alias: webburza_article_category }
+
+ webburza_article.form.type.article_category_translation:
+ class: '%webburza_article.form.type.article_category_translation.class%'
+ arguments:
+ - '%webburza_article.model.article_category_translation.class%'
+ tags:
+ - { name: form.type, alias: webburza_article_category_translation }
+
+ webburza_article.form.extension.article_translation_active:
+ class: '%webburza_article.form.extension.article_translation_active.class%'
+ arguments:
+ - "@=service('sylius.locale_provider').getAvailableLocalesCodes()"
+ tags:
+ - { name: form.type_extension, extended_type: '%webburza_article.form.type.article_translation.class%' }
+
+ webburza_article.form.extension.article_image_remove:
+ class: '%webburza_article.form.extension.article_image_remove.class%'
+ tags:
+ - { name: form.type_extension, extended_type: '%webburza_article.form.type.article.class%' }
diff --git a/Resources/translations/messages.en.yml b/Resources/translations/messages.en.yml
index 81998a5..53777f6 100644
--- a/Resources/translations/messages.en.yml
+++ b/Resources/translations/messages.en.yml
@@ -1,63 +1,39 @@
-webburza:
- sylius:
- article:
- backend:
- articles: Articles
- frontend:
- articles: Articles
- latest_from_category: 'Latest from category'
- related_articles: 'Related articles'
- latest_articles: 'Latest articles'
- breadcrumb:
- index: Articles
- index_header: Articles
- create_header: New article
- update_header: Editing article
- show_header: Article details
- create: Create article
- open: Open
- no_results: No articles found.
- translations: Translations
- general_info: General info
- related_products: Related products
- back_to_all: back to all articles
- delete_image: Delete image
- label:
- id: '#ID'
- title: Title
- lead: Lead
- content: Content
- active: Active?
- meta_keywords: Meta Keywords
- meta_description: Meta Description
- cover_image: Cover Image
- published_at: Published At
- published: Published?
- featured: Featured?
- created_at: Created At
- updated_at: Updated At
- products: Related products
- choose_products: Choose products...
- category: Category
- choose_category: Choose a category...
- file: File
- article_category:
- backend:
- article_categories: Article Categories
- breadcrumb:
- index: Article Categories
- index_header: Article Categories
- create_header: New category
- update_header: Editing category
- show_header: Category details
- create: Create category
- open: Open
- no_results: No categories found.
- translations: Translations
- general_info: General info
- label:
- id: '#ID'
- title: Title
- published: Published?
- created_at: Created At
- updated_at: Updated At
+webburza_article:
+ ui:
+ article: Article
+ articles: Articles
+ article_category: Article category
+ article_categories: Article categories
+ latest_from_category: Latest from category
+ related_articles: Related articles
+ related_products: Related products
+ content: Content
+ manage_articles: Manage articles
+ manage_article_categories: Manage article categories
+ article:
+ label:
+ id: Id
+ title: Title
+ lead: Lead
+ content: Content
+ active: Active?
+ meta_keywords: Meta Keywords
+ meta_description: Meta Description
+ cover_image: Cover Image
+ published_at: Published At
+ published: Published?
+ featured: Featured?
+ created_at: Created At
+ updated_at: Updated At
+ products: Related products
+ choose_products: Choose products...
+ category: Category
+ choose_category: Choose a category...
+ file: File
+ article_category:
+ label:
+ id: Id
+ title: Title
+ published: Published?
+ created_at: Created At
+ updated_at: Updated At
diff --git a/Resources/translations/messages.hr.yml b/Resources/translations/messages.hr.yml
deleted file mode 100644
index c6684f8..0000000
--- a/Resources/translations/messages.hr.yml
+++ /dev/null
@@ -1,63 +0,0 @@
-webburza:
- sylius:
- article:
- backend:
- articles: Članci
- frontend:
- articles: Članci
- latest_from_category: 'Najnovije iz kategorije'
- related_articles: 'Povezani članci'
- latest_articles: 'Najnoviji članci'
- breadcrumb:
- index: Članci
- index_header: Članci
- create_header: Novi članak
- update_header: Uređivanje članka
- show_header: Detalji članka
- create: Novi članak
- open: Otvori
- no_results: Nije pronađen niti jedan članak.
- translations: Prijevodi
- general_info: Općenite informacije
- related_products: Povezani proizvodi
- back_to_all: natrag na sve članke
- delete_image: Izbriši sliku
- label:
- id: '#ID'
- title: Naslov
- lead: Kratak opis
- content: Sadržaj
- active: Aktivno?
- meta_keywords: Meta ključne riječi
- meta_description: Meta opis
- cover_image: Noseća slika
- published_at: Datum objave
- published: Objavljeno?
- featured: Istaknuto?
- created_at: Datum kreiranja
- updated_at: Datum ažuriranja
- products: Povezani proizvodi
- choose_products: Odaberite proizvode...
- choose_category: Kategorija
- choose_category: Odaberite kategoriju...
- file: Datoteka
- article_category:
- backend:
- article_categories: Kategorije članaka
- breadcrumb:
- index: Kategorije članaka
- index_header: Kategorije članaka
- create_header: Nova kategorija
- update_header: Uređivanje kategorije
- show_header: Detalji kategorije
- create: Nova kategorija
- open: Otvori
- no_results: Nije pronađena niti jedna kategorija.
- translations: Prijevodi
- general_info: Općenite informacije
- label:
- id: '#ID'
- title: Naslov
- published: Objavljeno?
- created_at: Datum kreiranja
- updated_at: Datum ažuriranja
diff --git a/Resources/views/Backend/Article/Macros/macros.html.twig b/Resources/views/Backend/Article/Macros/macros.html.twig
deleted file mode 100644
index 4696599..0000000
--- a/Resources/views/Backend/Article/Macros/macros.html.twig
+++ /dev/null
@@ -1,56 +0,0 @@
-{% macro list(articles) %}
-
- {% import 'SyliusResourceBundle:Macros:buttons.html.twig' as buttons %}
- {% import 'SyliusWebBundle:Backend/Macros:alerts.html.twig' as alerts %}
-
- {% if articles|length > 0 %}
-
-
-
- {{ sylius_resource_sort('id', 'webburza.sylius.article.label.id'|trans) }}
- {{ sylius_resource_sort('translation.title', 'webburza.sylius.article.label.title'|trans) }}
- {{ 'webburza.sylius.article.label.cover_image'|trans }}
- {{ sylius_resource_sort('publishedAt', 'webburza.sylius.article.label.published_at'|trans) }}
- {{ sylius_resource_sort('updatedAt', 'webburza.sylius.article.label.updated_at'|trans) }}
-
-
-
-
- {% for article in articles %}
-
- {{ article.id }}
-
-
- {{ article.title }}
-
-
-
- {% if article.image %}
-
-
-
- {% else %}
- —
- {% endif %}
-
-
- {% if (article.published and article.publishedAt) %}
- {{ article.publishedAt | date }}
- {% else %}
- —
- {% endif %}
-
- {{ article.updatedAt | date }}
-
- {{ buttons.edit(path('webburza_article_update', {'id': article.id})) }}
- {{ buttons.delete(path('webburza_article_delete', {'id': article.id})) }}
-
-
- {% endfor %}
-
-
- {% else %}
- {{ alerts.info('webburza.sylius.article.no_results'|trans) }}
- {% endif %}
-
-{% endmacro %}
diff --git a/Resources/views/Backend/Article/_form.html.twig b/Resources/views/Backend/Article/_form.html.twig
new file mode 100644
index 0000000..85170f7
--- /dev/null
+++ b/Resources/views/Backend/Article/_form.html.twig
@@ -0,0 +1,85 @@
+{% form_theme form with ['@SyliusUi/Form/theme.html.twig', _self] %}
+
+
+ {{ form_errors(form) }}
+
+
+
+
+ {% for locale, translationForm in form.translations %}
+
+
+
+ {{ locale|sylius_locale_name }}
+
+
+ {{ form_rest(translationForm) }}
+
+
+ {% endfor %}
+
+
+
+
+
+ {{ form_label(form.image) }}
+
+
+ {% if form.vars.data.image and form.vars.data.image.path %}
+
+
+
+ {% endif %}
+
+
+
+ {{ (form.vars.data.image ? 'sylius.ui.change_file' : 'sylius.ui.choose_file') | trans }}
+
+
+
+ {{ form_widget(form.image) }}
+
+
+ {% if form.vars.data.image %}
+
+
+ {{ 'sylius.ui.delete' | trans }}
+
+
+ {{ form_widget(form.imageRemove) }}
+ {% endif %}
+
+
+
+ {{ form_row(form.category) }}
+ {{ form_row(form.products) }}
+ {{ form_row(form.featured) }}
+ {{ form_row(form.published) }}
+ {{ form_row(form.publishedAt) }}
+
+
+
+
+
+
+
diff --git a/Resources/views/Backend/Article/_gridImage.html.twig b/Resources/views/Backend/Article/_gridImage.html.twig
new file mode 100644
index 0000000..04ba434
--- /dev/null
+++ b/Resources/views/Backend/Article/_gridImage.html.twig
@@ -0,0 +1,5 @@
+{% if data.image is not null %}
+
+
+
+{% endif %}
diff --git a/Resources/views/Backend/Article/_gridTitle.html.twig b/Resources/views/Backend/Article/_gridTitle.html.twig
new file mode 100644
index 0000000..fbdc460
--- /dev/null
+++ b/Resources/views/Backend/Article/_gridTitle.html.twig
@@ -0,0 +1,5 @@
+{% if data.published %}
+ {{ data.title }}
+{% else %}
+ {{ data.title }}
+{% endif %}
diff --git a/Resources/views/Backend/Article/create.html.twig b/Resources/views/Backend/Article/create.html.twig
deleted file mode 100644
index b46a63c..0000000
--- a/Resources/views/Backend/Article/create.html.twig
+++ /dev/null
@@ -1,41 +0,0 @@
-{% extends 'SyliusWebBundle:Backend:layout.html.twig' %}
-
-{% from 'SyliusResourceBundle:Macros:actions.html.twig' import create %}
-
-{% block topbar %}
-
- {{ 'sylius.ui.content'|trans }}
- {{ 'webburza.sylius.article.breadcrumb.index'|trans }}
- {{ 'sylius.ui.new'|trans }}
-
-{% endblock %}
-
-{% block content %}
-
-
-
-{% endblock %}
-
-{% block javascripts %}
- {{ parent() }}
-
- {% if app.request.get('browse_url') and app.request.get('upload_url') %}
-
- {% endif %}
-{% endblock %}
diff --git a/Resources/views/Backend/Article/index.html.twig b/Resources/views/Backend/Article/index.html.twig
deleted file mode 100755
index 824d6e8..0000000
--- a/Resources/views/Backend/Article/index.html.twig
+++ /dev/null
@@ -1,28 +0,0 @@
-{% extends 'SyliusWebBundle:Backend:layout.html.twig' %}
-
-{% import 'SyliusResourceBundle:Macros:buttons.html.twig' as buttons %}
-{% from 'SyliusWebBundle:Backend/Macros:misc.html.twig' import pagination %}
-{% from 'WebburzaSyliusArticleBundle:Backend/Article/Macros:macros.html.twig' import list %}
-
-{% block topbar %}
-
- {{ 'sylius.ui.content'|trans }}
- {{ 'webburza.sylius.article.breadcrumb.index'|trans }}
-
-{% endblock %}
-
-{% block content %}
-
-
- {{ pagination(articles) }}
- {{ list(articles) }}
- {{ pagination(articles) }}
-
-{% endblock %}
diff --git a/Resources/views/Backend/Article/show.html.twig b/Resources/views/Backend/Article/show.html.twig
deleted file mode 100644
index 7c9cc43..0000000
--- a/Resources/views/Backend/Article/show.html.twig
+++ /dev/null
@@ -1,168 +0,0 @@
-{% extends 'SyliusWebBundle:Backend:layout.html.twig' %}
-
-{% import 'SyliusResourceBundle:Macros:buttons.html.twig' as buttons %}
-{% import 'SyliusWebBundle:Backend/Macros:alerts.html.twig' as alerts %}
-{% import 'SyliusWebBundle:Backend/Macros:misc.html.twig' as misc %}
-
-{% block topbar %}
-
- {{ 'sylius.ui.content'|trans }}
- {{ 'webburza.sylius.article.breadcrumb.index'|trans }}
- {{ article.title }}
-
-{% endblock %}
-
-{% block content %}
-
-
-
-
-
-
{{ article.title }}
-
{{ article.content | raw }}
-
-
- {% if article.products is not empty %}
-
-
-
- {{ 'webburza.sylius.article.related_products'|trans }}
-
-
-
- {% for product in article.products %}
-
-
-
-
-
-
-
- {{ product.name }}
-
-
- {% endfor %}
-
-
- {% endif %}
-
-
-
-
-
-
- {{ 'webburza.sylius.article.general_info'|trans }}
-
-
-
-
- {{ 'webburza.sylius.article.label.id'|trans }}
- {{ article.id }}
-
-
- {{ 'webburza.sylius.article.label.title'|trans }}
- {{ article.title }}
-
-
- {{ 'webburza.sylius.article.label.lead'|trans }}
- {{ article.lead }}
-
-
- {{ 'webburza.sylius.article.label.meta_keywords'|trans }}
- {{ article.metaKeywords }}
-
-
- {{ 'webburza.sylius.article.label.meta_description'|trans }}
- {{ article.metaDescription }}
-
-
- {{ 'webburza.sylius.article.label.cover_image'|trans }}
-
- {% if article.image %}
-
-
-
-
-
- {% else %}
- —
- {% endif %}
-
-
-
- {{ 'webburza.sylius.article.label.category'|trans }}
-
- {% if article.category %}
- {{ article.category.title }}
- {% else %}
- —
- {% endif %}
-
-
-
- {{ 'webburza.sylius.article.label.published_at'|trans }}
-
- {% if (article.published and article.publishedAt) %}
- {{ article.publishedAt | date }}
- {% else %}
- —
- {% endif %}
-
-
-
- {{ 'webburza.sylius.article.label.published'|trans }}
-
- {% if article.published %}
-
- {% else %}
-
- {% endif %}
-
-
-
- {{ 'webburza.sylius.article.label.featured'|trans }}
-
- {% if article.featured %}
-
- {% else %}
-
- {% endif %}
-
-
-
- {{ 'webburza.sylius.article.label.created_at' | trans }}
- {{ article.createdAt | date }}
-
-
- {{ 'webburza.sylius.article.label.updated_at' | trans }}
-
- {% if (article.updatedAt) %}
- {{ article.updatedAt | date }}
- {% else %}
- —
- {% endif %}
-
-
-
-
-
-
-{% endblock %}
diff --git a/Resources/views/Backend/Article/update.html.twig b/Resources/views/Backend/Article/update.html.twig
deleted file mode 100644
index 4168ea9..0000000
--- a/Resources/views/Backend/Article/update.html.twig
+++ /dev/null
@@ -1,42 +0,0 @@
-{% extends 'SyliusWebBundle:Backend:layout.html.twig' %}
-
-{% from 'SyliusResourceBundle:Macros:actions.html.twig' import update %}
-
-{% block topbar %}
-
- {{ 'sylius.ui.content'|trans }}
- {{ 'webburza.sylius.article.breadcrumb.index'|trans }}
- {{ 'sylius.ui.edit'|trans }}
-
-{% endblock %}
-
-{% block content %}
-
-
-
-{% endblock %}
-
-{% block javascripts %}
- {{ parent() }}
-
- {% if app.request.get('browse_url') and app.request.get('upload_url') %}
-
- {% endif %}
-{% endblock %}
diff --git a/Resources/views/Backend/ArticleCategory/_form.html.twig b/Resources/views/Backend/ArticleCategory/_form.html.twig
new file mode 100644
index 0000000..13ce93f
--- /dev/null
+++ b/Resources/views/Backend/ArticleCategory/_form.html.twig
@@ -0,0 +1,27 @@
+{% form_theme form with ['@SyliusUi/Form/theme.html.twig', _self] %}
+
+
+ {{ form_errors(form) }}
+
+
+
+
+ {% for locale, translationForm in form.translations %}
+
+
+
+ {{ locale|sylius_locale_name }}
+
+
+ {{ form_rest(translationForm) }}
+
+
+ {% endfor %}
+
+
+
+
+ {{ form_row(form.published) }}
+
+
+
diff --git a/Resources/views/Backend/Category/Macros/macros.html.twig b/Resources/views/Backend/Category/Macros/macros.html.twig
deleted file mode 100644
index 27d39a6..0000000
--- a/Resources/views/Backend/Category/Macros/macros.html.twig
+++ /dev/null
@@ -1,46 +0,0 @@
-{% macro list(article_categories) %}
-
- {% import 'SyliusResourceBundle:Macros:buttons.html.twig' as buttons %}
- {% import 'SyliusWebBundle:Backend/Macros:alerts.html.twig' as alerts %}
-
- {% if article_categories|length > 0 %}
-
-
-
- {{ sylius_resource_sort('id', 'webburza.sylius.article_category.label.id'|trans) }}
- {{ sylius_resource_sort('translation.title', 'webburza.sylius.article_category.label.title'|trans) }}
- {{ sylius_resource_sort('published', 'webburza.sylius.article_category.label.published'|trans) }}
- {{ sylius_resource_sort('updatedAt', 'webburza.sylius.article.label.updated_at'|trans) }}
-
-
-
-
- {% for article_category in article_categories %}
-
- {{ article_category.id }}
-
-
- {{ article_category.title }}
-
-
-
- {% if article_category.published %}
-
- {% else %}
-
- {% endif %}
-
- {{ article_category.updatedAt | date }}
-
- {{ buttons.edit(path('webburza_article_category_update', {'id': article_category.id})) }}
- {{ buttons.delete(path('webburza_article_category_delete', {'id': article_category.id})) }}
-
-
- {% endfor %}
-
-
- {% else %}
- {{ alerts.info('webburza.sylius.article_category.no_results'|trans) }}
- {% endif %}
-
-{% endmacro %}
diff --git a/Resources/views/Backend/Category/create.html.twig b/Resources/views/Backend/Category/create.html.twig
deleted file mode 100644
index d82d6fc..0000000
--- a/Resources/views/Backend/Category/create.html.twig
+++ /dev/null
@@ -1,26 +0,0 @@
-{% extends 'SyliusWebBundle:Backend:layout.html.twig' %}
-
-{% from 'SyliusResourceBundle:Macros:actions.html.twig' import create %}
-
-{% block topbar %}
-
- {{ 'sylius.ui.content'|trans }}
- {{ 'webburza.sylius.article_category.breadcrumb.index'|trans }}
- {{ 'sylius.ui.new'|trans }}
-
-{% endblock %}
-
-{% block content %}
-
-
-
-{% endblock %}
diff --git a/Resources/views/Backend/Category/index.html.twig b/Resources/views/Backend/Category/index.html.twig
deleted file mode 100755
index 403d99a..0000000
--- a/Resources/views/Backend/Category/index.html.twig
+++ /dev/null
@@ -1,28 +0,0 @@
-{% extends 'SyliusWebBundle:Backend:layout.html.twig' %}
-
-{% import 'SyliusResourceBundle:Macros:buttons.html.twig' as buttons %}
-{% from 'SyliusWebBundle:Backend/Macros:misc.html.twig' import pagination %}
-{% from 'WebburzaSyliusArticleBundle:Backend/Category/Macros:macros.html.twig' import list %}
-
-{% block topbar %}
-
- {{ 'sylius.ui.content'|trans }}
- {{ 'webburza.sylius.article_category.breadcrumb.index'|trans }}
-
-{% endblock %}
-
-{% block content %}
-
-
- {{ pagination(article_categories) }}
- {{ list(article_categories) }}
- {{ pagination(article_categories) }}
-
-{% endblock %}
diff --git a/Resources/views/Backend/Category/show.html.twig b/Resources/views/Backend/Category/show.html.twig
deleted file mode 100644
index c6352f7..0000000
--- a/Resources/views/Backend/Category/show.html.twig
+++ /dev/null
@@ -1,75 +0,0 @@
-{% extends 'SyliusWebBundle:Backend:layout.html.twig' %}
-
-{% import 'SyliusResourceBundle:Macros:buttons.html.twig' as buttons %}
-{% import 'SyliusWebBundle:Backend/Macros:alerts.html.twig' as alerts %}
-{% import 'SyliusWebBundle:Backend/Macros:misc.html.twig' as misc %}
-
-{% block topbar %}
-
- {{ 'sylius.ui.content'|trans }}
- {{ 'webburza.sylius.article_category.breadcrumb.index'|trans }}
- {{ article_category.title }}
-
-{% endblock %}
-
-{% block content %}
-
-
-
-
-
-
-
- {{ 'webburza.sylius.article_category.general_info'|trans }}
-
-
-
-
- {{ 'webburza.sylius.article_category.label.id'|trans }}
- {{ article_category.id }}
-
-
- {{ 'webburza.sylius.article_category.label.title'|trans }}
- {{ article_category.title }}
-
-
- {{ 'webburza.sylius.article_category.label.published'|trans }}
-
- {% if article_category.published %}
-
- {% else %}
-
- {% endif %}
-
-
-
- {{ 'webburza.sylius.article_category.label.created_at' | trans }}
- {{ article_category.createdAt | date }}
-
-
- {{ 'webburza.sylius.article_category.label.updated_at' | trans }}
-
- {% if (article_category.updatedAt) %}
- {{ article_category.updatedAt | date }}
- {% else %}
- —
- {% endif %}
-
-
-
-
-
-
-{% endblock %}
diff --git a/Resources/views/Backend/Category/update.html.twig b/Resources/views/Backend/Category/update.html.twig
deleted file mode 100644
index e1069ef..0000000
--- a/Resources/views/Backend/Category/update.html.twig
+++ /dev/null
@@ -1,27 +0,0 @@
-{% extends 'SyliusWebBundle:Backend:layout.html.twig' %}
-
-{% from 'SyliusResourceBundle:Macros:actions.html.twig' import update %}
-
-{% block topbar %}
-
- {{ 'sylius.ui.content'|trans }}
- {{ 'webburza.sylius.article_category.breadcrumb.index'|trans }}
- {{ 'sylius.ui.edit'|trans }}
-
-{% endblock %}
-
-{% block content %}
-
-
-
-{% endblock %}
diff --git a/Resources/views/Frontend/Article/_card.html.twig b/Resources/views/Frontend/Article/_card.html.twig
new file mode 100644
index 0000000..fe12c80
--- /dev/null
+++ b/Resources/views/Frontend/Article/_card.html.twig
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+ {{ article.publishedAt | date }}
+
+
+
+ {{ (article.lead | slice(0, 100)) ~ (article.lead | length > 100 ? '...' : '') }}
+
+
+
+
diff --git a/Resources/views/Frontend/Article/_related.html.twig b/Resources/views/Frontend/Article/_related.html.twig
new file mode 100644
index 0000000..85d94d3
--- /dev/null
+++ b/Resources/views/Frontend/Article/_related.html.twig
@@ -0,0 +1,15 @@
+
+
+
+
+ {% for article in articles %}
+ {% include 'WebburzaSyliusArticleBundle:Frontend/Article:_card.html.twig' %}
+ {% if 0 == loop.index % 4 %}
+
+
+ {% endif %}
+ {% endfor %}
+
+
diff --git a/Resources/views/Frontend/Article/index.html.twig b/Resources/views/Frontend/Article/index.html.twig
index 6cc66b6..3ce4245 100644
--- a/Resources/views/Frontend/Article/index.html.twig
+++ b/Resources/views/Frontend/Article/index.html.twig
@@ -1,29 +1,54 @@
-{% extends 'SyliusWebBundle:Frontend:layout.html.twig' %}
+{% extends '@SyliusShop/layout.html.twig' %}
-{% import 'WebburzaSyliusArticleBundle:Frontend/Article:macros.html.twig' as macro %}
-
-{% block title %}{{ 'webburza.sylius.article.index_header' | trans }}{% endblock %}
+{% import '@SyliusUi/Macro/pagination.html.twig' as pagination %}
+{% import 'SyliusUiBundle:Macro:messages.html.twig' as messages %}
{% block content %}
-
-
-{% if articles.haveToPaginate() %}
- {{ pagerfanta(articles, 'twitter_bootstrap3_translated') }}
-{% endif %}
+
+
{{ 'sylius.ui.home'|trans }}
+
/
-
-
-{% if categories is not empty %}
- {{ macro.articleSidebar(categories) }}
-{% endif %}
-
+
-{% if articles.haveToPaginate() %}
- {{ pagerfanta(articles, 'twitter_bootstrap3_translated') }}
-{% endif %}
+
+
+ {% if categories | length %}
+
+ {% endif %}
+
+
+ {% if articles | length > 0 %}
+
+ {% for article in articles %}
+ {% include 'WebburzaSyliusArticleBundle:Frontend/Article:_card.html.twig' %}
+ {% endfor %}
+
+
+ {{ pagination.simple(articles) }}
+ {% else %}
+ {{ messages.info('sylius.ui.no_results_to_display'|trans) }}
+ {% endif %}
+
+
{% endblock %}
diff --git a/Resources/views/Frontend/Article/macros.html.twig b/Resources/views/Frontend/Article/macros.html.twig
deleted file mode 100644
index d1b6d93..0000000
--- a/Resources/views/Frontend/Article/macros.html.twig
+++ /dev/null
@@ -1,71 +0,0 @@
-{% macro list(articles) %}
-{% import 'SyliusWebBundle:Backend/Macros:alerts.html.twig' as alerts %}
-
-{% for article in articles %}
-
-
-
-
-
- {{ article.title }}
-
-
-
{{ article.publishedAt|date }}
-
- {% if article.lead %}
-
-
-
{{ article.lead }}
- {% endif %}
-
-
-{% if not loop.last %}
{% endif %}
-{% else %}
-{{ alerts.info('webburza.sylius.article.no_results'|trans) }}
-{% endfor %}
-{% endmacro %}
-
-{% macro articleSidebar(categories, currentCategory, products, articleView) %}
-
- {% if categories is not empty %}
-
- {% endif %}
-
- {% if products is not empty %}
-
-
- {% for product in products %}
- {% if product.enabled %}
-
- {% endif %}
- {% endfor %}
- {% endif %}
-
-{% endmacro %}
diff --git a/Resources/views/Frontend/Article/show.html.twig b/Resources/views/Frontend/Article/show.html.twig
index f52057c..c946fed 100644
--- a/Resources/views/Frontend/Article/show.html.twig
+++ b/Resources/views/Frontend/Article/show.html.twig
@@ -1,52 +1,55 @@
-{% extends 'SyliusWebBundle:Frontend:layout.html.twig' %}
+{% extends "@SyliusShop/layout.html.twig" %}
-{% import 'WebburzaSyliusArticleBundle:Frontend/Article:macros.html.twig' as macro %}
+{% block content %}
+
+
-
-
-{% if article.image %}
-
+
+
+
-
-{% endif %}
+ {% if article.lead %}
+
{{ article.lead }}
+ {% endif %}
- {{ article.content|raw }}
-
+ {% if article.image %}
+
+ {% endif %}
-{% if categories is not empty or article.products is not empty %}
- {{ macro.articleSidebar(categories, article.category, article.products, true) }}
-{% endif %}
-
+
+ {{ article.content | raw }}
+
-{% if related_articles is not empty %}
-
+ {% if article.products | length %}
+
-
-
- {% if article.category %}
-
{{ 'webburza.sylius.article.frontend.latest_from_category' | trans }} "{{ article.category.title }}"
- {% else %}
- {{ 'webburza.sylius.article.frontend.latest_articles' | trans }}
- {% endif %}
+ {% include 'SyliusShopBundle:Product:_horizontalList.html.twig' with { products: article.products } %}
+ {% endif %}
- {{ macro.list(related_articles) }}
+ {% if relatedArticles | length %}
+ {% include 'WebburzaSyliusArticleBundle:Frontend/Article:_related.html.twig' with { articles: relatedArticles } %}
+ {% endif %}
+
-
-{% endif %}
{% endblock %}
diff --git a/Resources/views/Frontend/Category/show.html.twig b/Resources/views/Frontend/Category/show.html.twig
deleted file mode 100644
index 8eb079f..0000000
--- a/Resources/views/Frontend/Category/show.html.twig
+++ /dev/null
@@ -1,31 +0,0 @@
-{% extends 'SyliusWebBundle:Frontend:layout.html.twig' %}
-
-{% import 'WebburzaSyliusArticleBundle:Frontend/Article:macros.html.twig' as macro %}
-
-{% block title %}{{ category.title }}{% endblock %}
-
-{% block content %}
-
-
-{% if articles.haveToPaginate() %}
- {{ pagerfanta(articles, 'twitter_bootstrap3_translated') }}
-{% endif %}
-
-
-
- {{ macro.list(articles) }}
-
-
-{% if categories is not empty %}
- {{ macro.articleSidebar(categories, category) }}
-{% endif %}
-
-
-{% if articles.haveToPaginate() %}
- {{ pagerfanta(articles, 'twitter_bootstrap3_translated') }}
-{% endif %}
-{% endblock %}
diff --git a/composer.json b/composer.json
index 693628b..99c616d 100644
--- a/composer.json
+++ b/composer.json
@@ -23,7 +23,7 @@
"psr-4": { "Webburza\\Sylius\\ArticleBundle\\": "" }
},
"require": {
- "sylius/core": "^0.19"
+ "sylius/core": "^1.0@dev"
},
"require-dev": {
"phpunit/phpunit": "^4.8"