From b7556659aa125196533180c0150631e387bdadb1 Mon Sep 17 00:00:00 2001 From: Yousef Chanan Date: Tue, 21 Jun 2016 16:16:36 +0200 Subject: [PATCH 1/2] feature(compatibility): Update for increased compatibility --- EventListener/FrontendMenuBuilderListener.php | 4 +-- EventListener/MenuBuilderListener.php | 30 ++++++++++--------- Form/Type/ArticleCategoryTranslationType.php | 2 +- Form/Type/ArticleCategoryType.php | 2 +- Form/Type/ArticleTranslationType.php | 12 ++++---- Form/Type/ArticleType.php | 6 ++-- 6 files changed, 29 insertions(+), 27 deletions(-) diff --git a/EventListener/FrontendMenuBuilderListener.php b/EventListener/FrontendMenuBuilderListener.php index feaf863..efa264b 100644 --- a/EventListener/FrontendMenuBuilderListener.php +++ b/EventListener/FrontendMenuBuilderListener.php @@ -2,8 +2,8 @@ namespace Webburza\Sylius\ArticleBundle\EventListener; use Sylius\Bundle\WebBundle\Event\MenuBuilderEvent; -use Symfony\Component\Translation\DataCollectorTranslator; use Symfony\Component\Translation\Translator; +use Symfony\Component\Translation\TranslatorInterface; class FrontendMenuBuilderListener { @@ -12,7 +12,7 @@ class FrontendMenuBuilderListener */ protected $translator; - public function __construct(DataCollectorTranslator $translator) + public function __construct(TranslatorInterface $translator) { $this->translator = $translator; } diff --git a/EventListener/MenuBuilderListener.php b/EventListener/MenuBuilderListener.php index 52ce5de..deae091 100644 --- a/EventListener/MenuBuilderListener.php +++ b/EventListener/MenuBuilderListener.php @@ -2,8 +2,8 @@ namespace Webburza\Sylius\ArticleBundle\EventListener; use Sylius\Bundle\WebBundle\Event\MenuBuilderEvent; -use Symfony\Component\Translation\DataCollectorTranslator; use Symfony\Component\Translation\Translator; +use Symfony\Component\Translation\TranslatorInterface; class MenuBuilderListener { @@ -12,7 +12,7 @@ class MenuBuilderListener */ protected $translator; - public function __construct(DataCollectorTranslator $translator) + public function __construct(TranslatorInterface $translator) { $this->translator = $translator; } @@ -21,18 +21,20 @@ public function addBackendMenuItems(MenuBuilderEvent $event) { $menu = $event->getMenu(); - $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')); + 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')); + $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')); + } } } diff --git a/Form/Type/ArticleCategoryTranslationType.php b/Form/Type/ArticleCategoryTranslationType.php index c247320..d197343 100644 --- a/Form/Type/ArticleCategoryTranslationType.php +++ b/Form/Type/ArticleCategoryTranslationType.php @@ -16,7 +16,7 @@ class ArticleCategoryTranslationType extends AbstractResourceType */ public function buildForm(FormBuilderInterface $builder, array $options) { - $builder->add('title', Type\TextType::class, [ + $builder->add('title', 'text', [ 'label' => 'webburza.sylius.article_category.label.title' ]); } diff --git a/Form/Type/ArticleCategoryType.php b/Form/Type/ArticleCategoryType.php index 132c886..2298c16 100644 --- a/Form/Type/ArticleCategoryType.php +++ b/Form/Type/ArticleCategoryType.php @@ -21,7 +21,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'label' => 'webburza.sylius.article_category.translations' ]); - $builder->add('published', Type\CheckboxType::class, [ + $builder->add('published', 'checkbox', [ 'label' => 'webburza.sylius.article_category.label.published' ]); } diff --git a/Form/Type/ArticleTranslationType.php b/Form/Type/ArticleTranslationType.php index de6e455..6e8f949 100644 --- a/Form/Type/ArticleTranslationType.php +++ b/Form/Type/ArticleTranslationType.php @@ -16,30 +16,30 @@ class ArticleTranslationType extends AbstractResourceType */ public function buildForm(FormBuilderInterface $builder, array $options) { - $builder->add('title', Type\TextType::class, [ + $builder->add('title', 'text', [ 'label' => 'webburza.sylius.article.label.title' ]); - $builder->add('lead', Type\TextareaType::class, [ + $builder->add('lead', 'textarea', [ 'label' => 'webburza.sylius.article.label.lead', 'attr' => ['rows' => 4] ]); - $builder->add('content', Type\TextareaType::class, [ + $builder->add('content', 'text', [ 'label' => 'webburza.sylius.article.label.content', 'attr' => ['class' => 'ckeditor'] ]); - $builder->add('active', Type\CheckboxType::class, [ + $builder->add('active', 'checkbox', [ 'label' => 'webburza.sylius.article.label.active' ]); - $builder->add('metaKeywords', Type\TextareaType::class, [ + $builder->add('metaKeywords', 'textarea', [ 'label' => 'webburza.sylius.article.label.meta_keywords', 'attr' => ['rows' => 2] ]); - $builder->add('metaDescription', Type\TextareaType::class, [ + $builder->add('metaDescription', 'textarea', [ 'label' => 'webburza.sylius.article.label.meta_description', 'attr' => ['rows' => 2] ]); diff --git a/Form/Type/ArticleType.php b/Form/Type/ArticleType.php index 8d284e1..cd0467d 100644 --- a/Form/Type/ArticleType.php +++ b/Form/Type/ArticleType.php @@ -41,7 +41,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'multiple' => true ]); - $builder->add('publishedAt', Type\DateTimeType::class, [ + $builder->add('publishedAt', 'datetime', [ 'label' => 'webburza.sylius.article.label.published_at', 'required' => false, 'date_format' => 'y-M-d', @@ -49,11 +49,11 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'time_widget' => 'text' ]); - $builder->add('published', Type\CheckboxType::class, [ + $builder->add('published', 'checkbox', [ 'label' => 'webburza.sylius.article.label.published' ]); - $builder->add('featured', Type\CheckboxType::class, [ + $builder->add('featured', 'checkbox', [ 'label' => 'webburza.sylius.article.label.featured' ]); } From c4bde9e78af8a6227b1ab6984e604d4755b94e65 Mon Sep 17 00:00:00 2001 From: Yousef Chanan Date: Thu, 23 Jun 2016 09:37:41 +0200 Subject: [PATCH 2/2] fix(article-form): Fix form element type for content --- Form/Type/ArticleTranslationType.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Form/Type/ArticleTranslationType.php b/Form/Type/ArticleTranslationType.php index 6e8f949..5f71879 100644 --- a/Form/Type/ArticleTranslationType.php +++ b/Form/Type/ArticleTranslationType.php @@ -25,7 +25,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'attr' => ['rows' => 4] ]); - $builder->add('content', 'text', [ + $builder->add('content', 'textarea', [ 'label' => 'webburza.sylius.article.label.content', 'attr' => ['class' => 'ckeditor'] ]);