Skip to content

Yet some others deprecations to cleanup #349

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions Bundle/BlogBundle/Entity/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Victoire\Bundle\BusinessPageBundle\Entity\BusinessTemplate;
use Victoire\Bundle\CoreBundle\Annotations as VIC;
use Victoire\Bundle\MediaBundle\Entity\Media;
use Victoire\Bundle\PageBundle\Entity\PageStatus;

/**
* @ORM\Entity(repositoryClass="Victoire\Bundle\BlogBundle\Repository\ArticleRepository"))
Expand All @@ -22,11 +23,6 @@ class Article
use BusinessEntityTrait;
use TimestampableEntity;

const DRAFT = 'draft';
const PUBLISHED = 'published';
const UNPUBLISHED = 'unpublished';
const SCHEDULED = 'scheduled';

/**
* @VIC\BusinessProperty("businessParameter")
* @ORM\Column(name="id", type="integer")
Expand Down Expand Up @@ -161,7 +157,7 @@ public function __toString()
*/
public function __construct()
{
$this->status = self::DRAFT;
$this->status = PageStatus::DRAFT;
}

/**
Expand Down Expand Up @@ -263,7 +259,7 @@ public function getCategory()
*/
public function getPublishedAt()
{
if ($this->status == self::PUBLISHED && $this->publishedAt === null) {
if ($this->status == PageStatus::PUBLISHED && $this->publishedAt === null) {
$this->setPublishedAt($this->getCreatedAt());
}

Expand Down Expand Up @@ -445,7 +441,7 @@ public function getTemplate()
*/
public function setStatus($status)
{
if ($status == self::PUBLISHED && $this->publishedAt === null) {
if ($status == PageStatus::PUBLISHED && $this->publishedAt === null) {
$this->setPublishedAt(new \DateTime());
}
$this->status = $status;
Expand Down
23 changes: 11 additions & 12 deletions Bundle/BlogBundle/Filter/TagFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$tagsChoices = [];

foreach ($tags as $tag) {
$tagsChoices[$tag->getId()] = $tag->getTitle();
$tagsChoices[$tag->getTitle()] = $tag->getId();
}

$data = null;
Expand All @@ -105,17 +105,16 @@ public function buildForm(FormBuilderInterface $builder, array $options)
}

$builder
->add(
'tags', ChoiceType::class, [
'label' => false,
'choices' => $tagsChoices,
'empty_value' => 'blog.tag_filter.empty_value',
'required' => false,
'expanded' => true,
'multiple' => $options['multiple'],
'data' => $data,
]
);
->add('tags', ChoiceType::class, [
'choices_as_values' => true,
'label' => false,
'choices' => $tagsChoices,
'empty_value' => 'blog.tag_filter.empty_value',
'required' => false,
'expanded' => true,
'multiple' => $options['multiple'],
'data' => $data,
]);
}

/**
Expand Down
25 changes: 10 additions & 15 deletions Bundle/BlogBundle/Form/ArticleSettingsType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Victoire\Bundle\BlogBundle\Entity\Article;
use Victoire\Bundle\FormBundle\Form\Type\SlugType;
use Victoire\Bundle\MediaBundle\Form\Type\MediaType;
use Victoire\Bundle\PageBundle\Entity\PageStatus;

/**
* Edit Article Type.
*/
class ArticleSettingsType extends ArticleType
{
/**
Expand All @@ -31,12 +28,13 @@ public function buildForm(FormBuilderInterface $builder, array $options)
->add('status', ChoiceType::class, [
'label' => 'form.page.type.status.label',
'choices' => [
Article::DRAFT => 'form.page.type.status.choice.label.draft',
Article::PUBLISHED => 'form.page.type.status.choice.label.published',
Article::UNPUBLISHED => 'form.page.type.status.choice.label.unpublished',
Article::SCHEDULED => 'form.page.type.status.choice.label.scheduled',
'form.page.type.status.choice.label.draft' => PageStatus::DRAFT,
'form.page.type.status.choice.label.published' => PageStatus::PUBLISHED,
'form.page.type.status.choice.label.unpublished' => PageStatus::UNPUBLISHED,
'form.page.type.status.choice.label.scheduled' => PageStatus::SCHEDULED,
],
'attr' => [
'choices_as_values' => true,
'attr' => [
'data-refreshOnChange' => 'true',
],
])
Expand All @@ -63,18 +61,15 @@ public function buildForm(FormBuilderInterface $builder, array $options)
public static function manageRelatedStatus($status, $form)
{
switch ($status) {
case Article::SCHEDULED:
$form
->add('publishedAt', null, [
case PageStatus::SCHEDULED:
$form->add('publishedAt', null, [
'widget' => 'single_text',
'vic_datetimepicker' => true,
'label' => 'form.article.settings.type.publish.label',
]);
break;
default:
$form
->remove('publishedAt');

$form->remove('publishedAt');
break;
}
}
Expand Down
3 changes: 1 addition & 2 deletions Bundle/BlogBundle/Form/ArticleType.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ protected function manageCategories($blogId, $form)
'label' => 'form.article.category.label',
'class' => 'Victoire\\Bundle\\BlogBundle\\Entity\\Category',
'query_builder' => $queryBuilder,
'empty_value' => 'Pas de catégorie', //@todo translate this #easypick
'empty_data' => null,
'placeholder' => 'form.article.category.placeholder',
]);
}

Expand Down
9 changes: 5 additions & 4 deletions Bundle/BlogBundle/Form/BlogSettingsType.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ public function buildForm(FormBuilderInterface $builder, array $options)
->add('status', ChoiceType::class, [
'label' => 'form.page.type.status.label',
'choices' => [
PageStatus::DRAFT => 'form.page.type.status.choice.label.draft',
PageStatus::PUBLISHED => 'form.page.type.status.choice.label.published',
PageStatus::UNPUBLISHED => 'form.page.type.status.choice.label.unpublished',
PageStatus::SCHEDULED => 'form.page.type.status.choice.label.scheduled',
'form.page.type.status.choice.label.draft' => PageStatus::DRAFT,
'form.page.type.status.choice.label.published' => PageStatus::PUBLISHED,
'form.page.type.status.choice.label.unpublished' => PageStatus::UNPUBLISHED,
'form.page.type.status.choice.label.scheduled' => PageStatus::SCHEDULED,
],
'choices_as_values' => true,
])
->add('publishedAt', null, [
'widget' => 'single_text',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function setDefaultDateValue(WidgetFilterSetDefaultValueEvent $event)
$options = $form->getConfig()->getOptions()['data'];
$years = $months = $days = [];
foreach ($articles as $key => $_article) {
$years[$_article->getPublishedAt()->format('Y')] = $_article->getPublishedAt()->format('Y');
$years[] = $_article->getPublishedAt()->format('Y');

if ($options->getFormat() != 'year') {
//init $months array
Expand All @@ -57,9 +57,8 @@ public function setDefaultDateValue(WidgetFilterSetDefaultValueEvent $event)
$form->add('defaultValue', ChoiceType::class, [
'label' => 'widget_filter.form.date.default.label',
'choices' => $years,
'empty_value' => 'widget_filter.form.date.default.empty_value.label',
]
);
'placeholder' => 'widget_filter.form.date.default.empty_value.label',
]);
}
}
}
9 changes: 5 additions & 4 deletions Bundle/BlogBundle/Listener/BlogFilterListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,12 @@ public function manageExtraFiltersFields(FormEvent $event)
$form->add('format', ChoiceType::class, [
'label' => 'widget_filter.form.date.format.label',
'choices' => [
'year' => 'widget_filter.form.date.format.choices.year.label',
'month' => 'widget_filter.form.date.format.choices.month.label',
'day' => 'widget_filter.form.date.format.choices.day.label',
'widget_filter.form.date.format.choices.year.label' => 'year',
'widget_filter.form.date.format.choices.month.label' => 'month',
'widget_filter.form.date.format.choices.day.label' => 'day',
],
'attr' => [
'choices_as_values' => true,
'attr' => [
'data-refreshOnChange' => 'true',
],
]);
Expand Down
6 changes: 3 additions & 3 deletions Bundle/BlogBundle/Repository/ArticleRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query;
use Victoire\Bundle\BlogBundle\Entity\Article;
use Victoire\Bundle\BlogBundle\Entity\Blog;
use Victoire\Bundle\CoreBundle\Repository\StateFullRepositoryTrait;
use Victoire\Bundle\PageBundle\Entity\PageStatus;

/**
* The Article repository.
Expand All @@ -32,8 +32,8 @@ public function getAll($excludeUnpublished = false)
$this->qb
->andWhere('article.status = :status')
->orWhere('article.status = :scheduled_status AND article.publishedAt > :publicationDate')
->setParameter('status', Article::PUBLISHED)
->setParameter('scheduled_status', Article::SCHEDULED)
->setParameter('status', PageStatus::PUBLISHED)
->setParameter('scheduled_status', PageStatus::SCHEDULED)
->setParameter('publicationDate', new \DateTime());
}

Expand Down
4 changes: 4 additions & 0 deletions Bundle/BlogBundle/Resources/translations/victoire.en.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@
<source>form.article.settings.type.article.title</source>
<target>Article</target>
</trans-unit>
<trans-unit id="50" resname="form.article.category.placeholder">
<source>form.article.category.placeholder</source>
<target>Choose</target>
</trans-unit>
</body>
</file>
</xliff>
6 changes: 3 additions & 3 deletions Bundle/BlogBundle/Resources/translations/victoire.es.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@
<source>form.article.settings.type.article.title</source>
<target>Artículo</target>
</trans-unit>
<trans-unit id="50" resname="menu.blog.translate">
<source>menu.blog.translate</source>
<target>Traducir</target>
<trans-unit id="50" resname="form.article.category.placeholder">
<source>form.article.category.placeholder</source>
<target>Elegir</target>
</trans-unit>
</body>
</file>
Expand Down
6 changes: 3 additions & 3 deletions Bundle/BlogBundle/Resources/translations/victoire.fr.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@
<source>form.article.settings.type.article.title</source>
<target>Article</target>
</trans-unit>
<trans-unit id="50" resname="menu.blog.translate">
<source>menu.blog.translate</source>
<target>Traduire</target>
<trans-unit id="50" resname="form.article.category.placeholder">
<source>form.article.category.placeholder</source>
<target>Choisissez</target>
</trans-unit>
</body>
</file>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ public function buildForm(FormBuilderInterface $builder, array $options)
&& $this->businessEntityHelper->findByEntityClassname($options['data_class'])) {
$builder
->add('visibleOnFront', ChoiceType::class, [
'choices' => [
1 => 'businessEntity.form.visibleOnFront.yes',
0 => 'businessEntity.form.visibleOnFront.no',
],
'label' => 'businessEntity.form.visibleOnFront.label',
'translation_domain' => 'victoire',
]
);
'choices' => [
'businessEntity.form.visibleOnFront.yes' => 1,
'businessEntity.form.visibleOnFront.no' => 0,
],
'choices_as_values' => true,
'label' => 'businessEntity.form.visibleOnFront.label',
'translation_domain' => 'victoire',
]);
}
}

Expand Down
8 changes: 4 additions & 4 deletions Bundle/BusinessPageBundle/Form/BusinessTemplateType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Victoire\Bundle\BusinessPageBundle\Form;

use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\OptionsResolver\OptionsResolver;
Expand Down Expand Up @@ -57,7 +58,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'description' => 'victoire.form.business_template.slug.vic_business_property_picker',
],
])
->add('businessEntityId', 'hidden');
->add('businessEntityId', HiddenType::class);
}

/**
Expand All @@ -67,10 +68,9 @@ public function configureOptions(OptionsResolver $resolver)
{
parent::configureOptions($resolver);
$resolver->setDefined(['businessProperty']);

$resolver->setDefaults([
'data_class' => 'Victoire\Bundle\BusinessPageBundle\Entity\BusinessTemplate',
'translation_domain' => 'victoire',
'data_class' => 'Victoire\Bundle\BusinessPageBundle\Entity\BusinessTemplate',
'translation_domain' => 'victoire',
]);
}
}
2 changes: 1 addition & 1 deletion Bundle/CoreBundle/Form/EntityProxyFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
->add($options['business_entity_id'], EntityType::class, [
'label' => false,
'required' => false,
'empty_value' => 'entity_proxy.form.empty_value',
'placeholder' => 'entity_proxy.form.empty_value',
'class' => $options['namespace'],
'attr' => [
'class' => 'add_'.$options['business_entity_id'].'_link picker_entity_select',
Expand Down
23 changes: 10 additions & 13 deletions Bundle/CoreBundle/Form/ViewType.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ public function __construct($availableLocales, RequestStack $requestStack)
*
* @param FormBuilderInterface $builder
* @param array $options
*
* @return null
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
Expand Down Expand Up @@ -66,16 +64,16 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'query_builder' => $getAllTemplateWithoutMe,
]);
}
if (!$form->has('locale') && count($choices = $this->getAvailableLocales($view)) > 1) {
if (!$form->has('locale') && count($choices = $this->getAvailableLocales()) > 1) {
$data = $view->getLocale() ?: $this->currentLocale;
$form->add('locale', ChoiceType::class, [
'expanded' => false,
'multiple' => false,
'choices' => $choices,
'label' => 'form.view.type.locale.label',
'data' => $data,
]
);
'expanded' => false,
'multiple' => false,
'choices' => $choices,
'choices_as_values' => true,
'label' => 'form.view.type.locale.label',
'data' => $data,
]);
}

//If view is an Article BEP, we do not allow to choose parent because it will be set automatically
Expand Down Expand Up @@ -109,13 +107,12 @@ public function buildForm(FormBuilderInterface $builder, array $options)
]);
}

protected function getAvailableLocales(View $view)
protected function getAvailableLocales()
{
$choices = [];
$i18n = $view->getI18n();

foreach ($this->availableLocales as $localeVal) {
$choices[$localeVal] = 'victoire.i18n.viewType.locale.'.$localeVal;
$choices['victoire.i18n.viewType.locale.'.$localeVal] = $localeVal;
}

return $choices;
Expand Down
Loading