Skip to content

Commit

Permalink
Merge pull request #81 from szymach/3.1
Browse files Browse the repository at this point in the history
Removed Symfony 2.x support
  • Loading branch information
rn0 authored Aug 7, 2019
2 parents 963b6b3 + 4357058 commit e2e445e
Show file tree
Hide file tree
Showing 35 changed files with 280 additions and 340 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ sudo: required
addons:
firefox: "47.0.1"

services:
- xvfb

matrix:
include:
- php: 7.1
env:
- COMPOSER_FLAGS='--prefer-lowest'
- php: 7.2
- php: 7.3

before_install:
- phpenv config-rm xdebug.ini
Expand All @@ -26,8 +29,6 @@ before_script:
- nohup php -S localhost:8080 -t features/fixtures/project/web > server.log 2>&1 &
- features/fixtures/project/app/console ckeditor:install --clear=skip
- features/fixtures/project/app/console assets:install --symlink features/fixtures/project/web
- sh -e /etc/init.d/xvfb start
- export DISPLAY=:99.0
- java -jar vendor/bin/selenium.jar > /dev/null 2>&1 &
- sleep 5

Expand Down
10 changes: 8 additions & 2 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,14 @@ public function __construct(array $adminTemplates)

public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('fsi_admin_translatable');
if (true === method_exists(TreeBuilder::class, 'getRootNode')) {
$treeBuilder = new TreeBuilder('fsi_admin_translatable');
$rootNode = $treeBuilder->getRootNode();
} else {
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('fsi_admin_translatable');
}

$rootNode
->children()
->arrayNode('locales')
Expand Down
10 changes: 3 additions & 7 deletions DependencyInjection/FSIAdminTranslatableExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@

namespace FSi\Bundle\AdminTranslatableBundle\DependencyInjection;

use FSi\Bundle\AdminTranslatableBundle\Form\TypeSolver;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

class FSIAdminTranslatableExtension extends Extension implements PrependExtensionInterface
{
Expand All @@ -41,10 +40,7 @@ public function load(array $configs, ContainerBuilder $container)
);
$loader->load('services.xml');
$loader->load('controller.xml');
$loader->load(TypeSolver::isSymfony3FormNamingConvention()
? 'form-symfony-3.xml'
: 'form-symfony-2.xml'
);
$loader->load('form.xml');
$loader->load('datagrid.xml');
$loader->load('menu.xml');

Expand Down
6 changes: 0 additions & 6 deletions Form/AbstractTranslatableExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,11 @@ abstract class AbstractTranslatableExtension extends AbstractTypeExtension
*/
protected $translatableFormHelper;

/**
* @param TranslatableFormHelper $translatableFormHelper
*/
public function __construct(TranslatableFormHelper $translatableFormHelper)
{
$this->translatableFormHelper = $translatableFormHelper;
}

/**
* {@inheritdoc}
*/
public function finishView(FormView $view, FormInterface $form, array $options)
{
$view->vars['translatable'] = false;
Expand Down
8 changes: 6 additions & 2 deletions Form/LocaleExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace FSi\Bundle\AdminTranslatableBundle\Form;

use Doctrine\Common\Persistence\ObjectManager;
use FSi\Bundle\AdminTranslatableBundle\Form\TypeSolver;
use FSi\DoctrineExtensions\Translatable\Mapping\ClassMetadata;
use FSi\DoctrineExtensions\Translatable\TranslatableListener;
use Symfony\Bridge\Doctrine\ManagerRegistry;
Expand Down Expand Up @@ -58,9 +57,14 @@ public static function getSubscribedEvents()
];
}

public static function getExtendedTypes()
{
return [FormType::class];
}

public function getExtendedType()
{
return TypeSolver::getFormType(FormType::class, 'form');
return FormType::class;
}

public function buildForm(FormBuilderInterface $formBuilder, array $options)
Expand Down
18 changes: 7 additions & 11 deletions Form/TranslatableCollectionExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace FSi\Bundle\AdminTranslatableBundle\Form;

use FSi\Bundle\AdminTranslatableBundle\Form\TypeSolver;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\FormBuilderInterface;

class TranslatableCollectionExtension extends AbstractSimpleTranslatableExtension
Expand All @@ -29,20 +29,16 @@ public function __construct(
$this->listener = $listener;
}

/**
* @inheritdoc
*/
public static function getExtendedTypes()
{
return [CollectionType::class];
}

public function getExtendedType()
{
return TypeSolver::getFormType(
'Symfony\Component\Form\Extension\Core\Type\CollectionType',
'collection'
);
return CollectionType::class;
}

/**
* @inheritdoc
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addEventSubscriber($this->listener);
Expand Down
3 changes: 2 additions & 1 deletion Form/TranslatableCollectionListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public function onPreSetData(FormEvent $event)
$parent = $this->translatableFormHelper->getFirstTranslatableParent($form);

if ($this->translatableFormHelper->isFormPropertyPathTranslatable($form)
&& !$this->translatableFormHelper->isFormDataInCurrentLocale($parent)) {
&& !$this->translatableFormHelper->isFormDataInCurrentLocale($parent)
) {
$event->setData(null);
}
}
Expand Down
25 changes: 6 additions & 19 deletions Form/TranslatableFSiRemovableFileExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace FSi\Bundle\AdminTranslatableBundle\Form;

use FSi\Bundle\AdminTranslatableBundle\Form\TypeSolver;
use FSi\Bundle\DoctrineExtensionsBundle\Form\Type\FSi\RemovableFileType;
use FSi\Bundle\DoctrineExtensionsBundle\Resolver\FSiFilePathResolver;
use Symfony\Component\Form\FormInterface;
Expand All @@ -32,33 +31,21 @@ public function __construct(
$this->filePathResolver = $filePathResolver;
}

/**
* @inheritdoc
*/
public static function getExtendedTypes()
{
return [RemovableFileType::class];
}

public function getExtendedType()
{
return TypeSolver::getFormType(
RemovableFileType::class,
'fsi_removable_file'
);
return RemovableFileType::class;
}

/**
* @param FormView $view
* @param FormInterface $form
* @param array $options
* @return bool
*/
protected function hasCurrentValue(FormView $view, FormInterface $form, array $options): bool
{
return isset($view[$form->getName()]->vars['data']);
}

/**
* @param FormView $view
* @param FormInterface $form
* @param array $options
*/
protected function moveCurrentValueToDefaultLocaleValue(
FormView $view,
FormInterface $form,
Expand Down
12 changes: 7 additions & 5 deletions Form/TranslatableTextExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@

namespace FSi\Bundle\AdminTranslatableBundle\Form;

use FSi\Bundle\AdminTranslatableBundle\Form\TypeSolver;
use Symfony\Component\Form\Extension\Core\Type\TextType;

class TranslatableTextExtension extends AbstractSimpleTranslatableExtension
{
/**
* @inheritdoc
*/
public static function getExtendedTypes()
{
return [TextType::class];
}

public function getExtendedType()
{
return TypeSolver::getFormType('Symfony\Component\Form\Extension\Core\Type\TextType', 'text');
return TextType::class;
}
}
40 changes: 0 additions & 40 deletions Form/TypeSolver.php

This file was deleted.

57 changes: 0 additions & 57 deletions Resources/config/form-symfony-2.xml

This file was deleted.

File renamed without changes.
Loading

0 comments on commit e2e445e

Please sign in to comment.