Skip to content
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

Upgrade/2.8 deprecations #343

Merged
merged 30 commits into from
Feb 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ed72fa4
upgrade vendors to go with sf 2.8, cleanup composer.json and fix brok…
Feb 19, 2016
dd14eee
[deprecation cleanup] request + flatten exception
Feb 19, 2016
b99da6d
[deprecation cleanup] violation use BuildViolation instead of addViol…
Feb 19, 2016
b55c82b
bigger screen to avoid mink errors (+ add 5sec wait)
Feb 19, 2016
7af1f4c
[deprecation cleanup] use configureOptions instead of setDefaultOptio…
Feb 19, 2016
7464519
rollback FlattenException use because of parent class which still use…
Feb 19, 2016
3241fe2
[deprecation cleanup] AuthorizationChecker / TokenStorage / optionsRe…
Feb 19, 2016
21dd960
[deprecation cleanup] Voter refactor
Feb 19, 2016
b3ab1ae
[deprecation cleanup] FormTypes
Feb 19, 2016
04b95ea
[deprecation cleanup] fix checkstyle
Feb 19, 2016
8c8a840
[deprecation cleanup] revert (weird) BusinessEntityTypeExtension exte…
Feb 19, 2016
e246344
HierarchyTree is a type, not an extension
Feb 19, 2016
482f999
[deprecation cleanup] FormTypes
Feb 19, 2016
8aa537b
[deprecation cleanup] FormType Extensions
Feb 19, 2016
7c5e88f
[deprecation cleanup] Functionnal project
Feb 19, 2016
c471957
[deprecation cleanup] Fix BlogCategory FormTypes issue
Feb 19, 2016
21cdda7
[deprecation cleanup] set dqcn to widget form types instead of alias
Feb 20, 2016
b185c78
[deprecation cleanup] FormTypes + fix behat tests
Feb 20, 2016
8d1d323
[deprecation cleanup] Seo and stylize form types
Feb 20, 2016
34544fa
fix widget delete action and page_settings_slug
Feb 20, 2016
121daa0
update friendsofvictoire widgets and set composer_root_version to 1.5
Feb 20, 2016
8e663c7
:lipstick: make WidgetType simpler
Feb 23, 2016
a7b305b
:arrow_up: :lipstick: up dependencies (and remove some bullshit from …
Feb 23, 2016
b19c2cd
:arrow_up: :lipstick: up dependencies
Feb 23, 2016
57a224f
:arrow_up: :lipstick: up dependencies (set symfony stable version)
Feb 23, 2016
fedc49d
:green_heart: fix fos_user.doctrine_registry by setting `alias: doctr…
Feb 23, 2016
5fb68bb
:green_heart: don't use useless mode variable and prefer $options
Feb 23, 2016
8daec2b
:lipstick: check style fixes
Feb 24, 2016
709a72b
:hammer: Upgrade widget generation
Feb 24, 2016
6e3e340
:memo: log changes and light up upgrade 1.2 file
Feb 24, 2016
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
13 changes: 8 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ php:
- 5.6

services:
- mysql
- redis-server

env:
Expand All @@ -20,7 +21,7 @@ before_script:
- mkdir fails
- composer self-update
- composer config --global github-oauth.github.com $gh_auth_token
- COMPOSER_ROOT_VERSION=dev-master composer install --prefer-dist
- COMPOSER_ROOT_VERSION=1.5 composer install --prefer-dist
# Prepare database
- php Tests/Functionnal/bin/console --env=test doctrine:database:create
- php Tests/Functionnal/bin/console --env=test doctrine:schema:create
Expand All @@ -39,6 +40,9 @@ before_script:
- "nohup java -jar selenium-server-standalone-2.49.0.jar > /dev/null &"
- sleep 5

script:
- './vendor/bin/behat'
- 'phpunit --coverage-text'

after_script:
- php Tests/Functionnal/bin/console --env=test doctrine:database:drop --force
Expand All @@ -47,10 +51,9 @@ after_failure:
- vendor/lakion/mink-debug-extension/travis/tools/upload-textfiles "fails/*.log"
- vendor/lakion/mink-debug-extension/travis/tools/upload-screenshots "fails/*.png"

script:
- './vendor/bin/behat'
- 'phpunit --coverage-text'

cache:
directories:
- $HOME/.composer/cache

notifications:
slack: appventus:Xy4yq4kXpBK9XHgfz8t9VBPl
8 changes: 5 additions & 3 deletions Bundle/BlogBundle/Controller/ArticleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
use Victoire\Bundle\BlogBundle\Entity\Blog;
use Victoire\Bundle\BlogBundle\Entity\Tag;
use Victoire\Bundle\BlogBundle\Event\ArticleEvent;
use Victoire\Bundle\BlogBundle\Form\ArticleSettingsType;
use Victoire\Bundle\BlogBundle\Form\ArticleType;
use Victoire\Bundle\BlogBundle\VictoireBlogEvents;

/**
Expand All @@ -35,7 +37,7 @@ public function createAction(Blog $blog)
$entityManager = $this->get('doctrine.orm.entity_manager');
$article = new Article();
$article->setBlog($blog);
$form = $this->createForm('victoire_article_type', $article);
$form = $this->createForm(ArticleType::class, $article);

$form->handleRequest($this->get('request'));
if ($form->isValid()) {
Expand Down Expand Up @@ -106,7 +108,7 @@ public function newBlogArticleAction(Blog $blog)
$article = new Article();
$article->setBlog($blog);
try {
$form = $this->createForm('victoire_article_type', $article);
$form = $this->createForm(ArticleType::class, $article);
} catch (NoResultException $e) {
return new JsonResponse(['success' => false, 'message' => $e->getMessage()]);
}
Expand Down Expand Up @@ -135,7 +137,7 @@ public function newBlogArticleAction(Blog $blog)
*/
public function settingsAction(Request $request, Article $article)
{
$form = $this->createForm('victoire_article_settings_type', $article);
$form = $this->createForm(ArticleSettingsType::class, $article);
$pageHelper = $this->get('victoire_page.page_helper');
$businessProperties = [];

Expand Down
13 changes: 8 additions & 5 deletions Bundle/BlogBundle/Controller/BlogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Victoire\Bundle\BlogBundle\Entity\Blog;
use Victoire\Bundle\BlogBundle\Form\BlogCategoryType;
use Victoire\Bundle\BlogBundle\Form\BlogSettingsType;
use Victoire\Bundle\BlogBundle\Form\BlogType;
use Victoire\Bundle\BlogBundle\Form\ChooseBlogType;
use Victoire\Bundle\BlogBundle\Repository\BlogRepository;
use Victoire\Bundle\BusinessPageBundle\Entity\BusinessTemplate;
Expand Down Expand Up @@ -61,13 +64,13 @@ public function indexAction(Request $request, $blogId = null, $tab = 'articles')
}
$options['blog'] = $blog;
$template = $this->getBaseTemplatePath().':index.html.twig';
$chooseBlogForm = $this->createForm(new ChooseBlogType(), null, $options);
$chooseBlogForm = $this->createForm(ChooseBlogType::class, null, $options);

$chooseBlogForm->handleRequest($request);
if ($chooseBlogForm->isValid()) {
$blog = $chooseBlogForm->getData()['blog'];
$template = $this->getBaseTemplatePath().':_blogItem.html.twig';
$chooseBlogForm = $this->createForm(new ChooseBlogType(), null, ['blog' => $blog]);
$chooseBlogForm = $this->createForm(ChooseBlogType::class, null, ['blog' => $blog]);
}
$businessProperties = [];

Expand Down Expand Up @@ -299,23 +302,23 @@ public function deleteAction(BasePage $blog)
*/
protected function getPageSettingsType()
{
return 'victoire_blog_settings_type';
return BlogSettingsType::class;
}

/**
* @return string
*/
protected function getPageCategoryType()
{
return 'victoire_blog_category_type';
return BlogCategoryType::class;
}

/**
* @return string
*/
protected function getNewPageType()
{
return 'victoire_blog_type';
return BlogType::class;
}

/**
Expand Down
40 changes: 14 additions & 26 deletions Bundle/BlogBundle/Filter/CategoryFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Translation\TranslatorInterface;
use Victoire\Bundle\BlogBundle\Entity\Category;
use Victoire\Bundle\FilterBundle\Filter\BaseFilter;
Expand All @@ -14,19 +15,16 @@
*/
class CategoryFilter extends BaseFilter
{
protected $em;
protected $request;
protected $translator;

/**
* @param EntityManager $em
* @param \Victoire\Bundle\FilterBundle\Filter\Request $request
* @param TranslatorInterface $translator
* @param EntityManager $entityManager
* @param Request $request
* @param TranslatorInterface $translator
*/
public function __construct(EntityManager $em, $request, TranslatorInterface $translator)
public function __construct(EntityManager $entityManager, Request $request, TranslatorInterface $translator)
{
$this->em = $em;
$this->request = $request;
parent::__construct($entityManager, $request);
$this->translator = $translator;
}

Expand All @@ -50,14 +48,14 @@ public function buildQuery(QueryBuilder $qb, array $parameters)
if ($parameter === '') {
unset($parameters['category'][$index]);
} else {
$parentCategory = $this->em->getRepository('VictoireBlogBundle:Category')->findOneById($parameter);
$parentCategory = $this->getEntityManager()->getRepository('VictoireBlogBundle:Category')->findOneById($parameter);
$childrenArray = array_merge($childrenArray, $this->getCategoryChildrens($parentCategory, []));
}
}

if (count($childrenArray) > 0) {
if (array_key_exists('strict', $parameters)) {
$repository = $this->em->getRepository('VictoireBlogBundle:Article');
$repository = $this->getEntityManager()->getRepository('VictoireBlogBundle:Article');
foreach ($childrenArray as $index => $category) {
$parameter = ':category'.$index;
$subquery = $repository->createQueryBuilder('article_'.$index)
Expand Down Expand Up @@ -101,9 +99,9 @@ public function buildForm(FormBuilderInterface $builder, array $options)
{

//getAll categories
$categoryQb = $this->em->getRepository('VictoireBlogBundle:Category')->getAll();
$categoryQb = $this->getEntityManager()->getRepository('VictoireBlogBundle:Category')->getAll();
//getAll published articles
$articleQb = $this->em->getRepository('VictoireBlogBundle:Article')->getAll(true);
$articleQb = $this->getEntityManager()->getRepository('VictoireBlogBundle:Article')->getAll(true);

//get Listing
$listing = $options['widget']->getListing();
Expand All @@ -128,14 +126,14 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$categoryQb->clearInstance();
$articleQb->clearInstance();
$data = null;
if ($this->request->query->has('filter') && array_key_exists('category_filter', $this->request->query->get('filter'))) {
if ($this->getRequest()->query->has('filter') && array_key_exists('category_filter', $this->getRequest()->query->get('filter'))) {
if ($options['multiple']) {
$data = [];
foreach ($this->request->query->get('filter')['category_filter']['category'] as $id => $selectedCategory) {
foreach ($this->getRequest()->query->get('filter')['category_filter']['category'] as $id => $selectedCategory) {
$data[$id] = $selectedCategory;
}
} else {
$data = $this->request->query->get('filter')['category_filter']['tags'];
$data = $this->getRequest()->query->get('filter')['category_filter']['tags'];
}
}
$builder
Expand Down Expand Up @@ -199,16 +197,6 @@ public function buildHierarchy($categories, $validCategories)
*/
public function getFilters($filters)
{
return $this->em->getRepository('VictoireBlogBundle:Category')->findById($filters['category']);
}

/**
* get form name.
*
* @return string name
*/
public function getName()
{
return 'category_filter';
return $this->getEntityManager()->getRepository('VictoireBlogBundle:Category')->findById($filters['category']);
}
}
53 changes: 8 additions & 45 deletions Bundle/BlogBundle/Filter/DateFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Victoire\Bundle\BlogBundle\Filter;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Victoire\Bundle\FilterBundle\Filter\BaseFilter;

Expand All @@ -12,21 +12,6 @@
*/
class DateFilter extends BaseFilter
{
protected $em;
protected $request;

/**
* Constructor.
*
* @param EntityManager $em
* @param unknown $request
*/
public function __construct(EntityManager $em, $request)
{
$this->em = $em;
$this->request = $request;
}

/**
* Build the query.
*
Expand All @@ -37,7 +22,7 @@ public function __construct(EntityManager $em, $request)
*/
public function buildQuery(QueryBuilder $qb, array $parameters)
{
$emConfig = $this->em->getConfiguration();
$emConfig = $this->getEntityManager()->getConfiguration();
$emConfig->addCustomDatetimeFunction('YEAR', 'DoctrineExtensions\Query\Mysql\Year');
$emConfig->addCustomDatetimeFunction('MONTH', 'DoctrineExtensions\Query\Mysql\Month');
$emConfig->addCustomDatetimeFunction('DAY', 'DoctrineExtensions\Query\Mysql\Day');
Expand Down Expand Up @@ -68,7 +53,7 @@ public function buildQuery(QueryBuilder $qb, array $parameters)
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$articles = $this->em->getRepository('VictoireBlogBundle:Article')->getAll(true)->run();
$articles = $this->getEntityManager()->getRepository('VictoireBlogBundle:Article')->getAll(true)->run();
$years = $months = $days = [];
foreach ($articles as $key => $_article) {
$years[$_article->getPublishedAt()->format('Y')] = $_article->getPublishedAt()->format('Y');
Expand All @@ -91,19 +76,19 @@ public function buildForm(FormBuilderInterface $builder, array $options)
}

$data = ['year' => null, 'month' => null, 'day' => null];
if ($this->request->query->has('filter') && array_key_exists('date_filter', $this->request->query->get('filter'))) {
$_request = $this->request->query->get('filter')['date_filter'];
if ($this->getRequest()->query->has('filter') && array_key_exists('date_filter', $this->getRequest()->query->get('filter'))) {
$_request = $this->getRequest()->query->get('filter')['date_filter'];
$data = $_request;
}

if (in_array($options['widget']->getFormat(), ['year', 'month', 'day'])) {
if (!$data['year']) {
// set default value to date filter and set listing to request while not better way
$data['year'] = $options['widget']->getDefaultValue();
$this->request->query->replace(
$this->getRequest()->query->replace(
[
'filter' => [
$this->getName() => [
self::class => [
'year' => $options['widget']->getDefaultValue(),
],
'listing' => $options['widget']->getListing()->getId(),
Expand All @@ -113,7 +98,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
}
$builder
->add(
'year', 'choice', [
'year', ChoiceType::class, [
'label' => false,
'choices' => $years,
'required' => false,
Expand All @@ -125,26 +110,4 @@ public function buildForm(FormBuilderInterface $builder, array $options)
);
}
}

/**
* Get the filters.
*
* @param array $filters
*
* @return array The filters
*/
public function getFilters($filters)
{
return $this->em->getRepository('VictoireBlogBundle:Article')->findAll();
}

/**
* get form name.
*
* @return string name
*/
public function getName()
{
return 'date_filter';
}
}
Loading