Skip to content
This repository has been archived by the owner on Jul 22, 2022. It is now read-only.

Commit

Permalink
Merge 2.x into master
Browse files Browse the repository at this point in the history
  • Loading branch information
SonataCI committed Oct 2, 2019
2 parents 1706e75 + 890b8b2 commit cde9f9a
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 12 deletions.
5 changes: 4 additions & 1 deletion composer.json
Expand Up @@ -38,6 +38,9 @@
"symfony/options-resolver": "^2.8 || ^3.2 || ^4.0",
"symfony/property-access": "^2.8 || ^3.2 || ^4.0"
},
"conflict": {
"sonata-project/doctrine-extensions": "<=1.3.0"
},
"provide": {
"sonata-project/admin-bundle-persistency-layer": "1.0.0"
},
Expand All @@ -49,7 +52,7 @@
"phpcr/phpcr-utils": "^1.4.0",
"sebastian/environment": "^1.3.4",
"sebastian/exporter": "^2.0",
"sonata-project/core-bundle": "^3.8",
"sonata-project/core-bundle": "^3.14",
"symfony-cmf/resource": "^1.0",
"symfony-cmf/resource-bundle": "^1.0",
"symfony-cmf/testing": "^2.1.12",
Expand Down
6 changes: 6 additions & 0 deletions src/Builder/FormContractor.php
Expand Up @@ -146,6 +146,12 @@ public function getDefaultOptions($type, FieldDescriptionInterface $fieldDescrip

break;
case 'Sonata\CoreBundle\Form\Type\CollectionType':
case 'sonata_type_collection_legacy':
/*
* NEXT_MAJOR: Remove 'Sonata\CoreBundle\Form\Type\CollectionType' and 'sonata_type_collection_legacy'
* cases when replace SonataCoreBundle by SonataFormExtension
*/
case 'Sonata\Form\Type\CollectionType':
case 'sonata_type_collection':
if (!$fieldDescription->getAssociationAdmin()) {
throw $this->getAssociationAdminException($fieldDescription);
Expand Down
2 changes: 1 addition & 1 deletion src/Filter/BooleanFilter.php
Expand Up @@ -14,8 +14,8 @@
namespace Sonata\DoctrinePHPCRAdminBundle\Filter;

use Sonata\AdminBundle\Datagrid\ProxyQueryInterface;
use Sonata\CoreBundle\Form\Type\BooleanType;
use Sonata\DoctrinePHPCRAdminBundle\Filter\Filter as BaseFilter;
use Sonata\Form\Type\BooleanType;

class BooleanFilter extends BaseFilter
{
Expand Down
13 changes: 12 additions & 1 deletion src/Form/Extension/CollectionTypeExtension.php
Expand Up @@ -14,6 +14,7 @@
namespace Sonata\DoctrinePHPCRAdminBundle\Form\Extension;

use Sonata\DoctrinePHPCRAdminBundle\Form\Listener\CollectionOrderListener;
use Sonata\Form\Type\CollectionType;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvents;
Expand Down Expand Up @@ -41,6 +42,16 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
*/
public function getExtendedType()
{
return 'Sonata\CoreBundle\Form\Type\CollectionType';
return self::getExtendedTypes()[0];
}

/**
* {@inheritdoc}
*/
public static function getExtendedTypes()
{
return [
CollectionType::class,
];
}
}
59 changes: 59 additions & 0 deletions src/Form/Extension/LegacyCollectionTypeExtension.php
@@ -0,0 +1,59 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Sonata Project package.
*
* (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Sonata\DoctrinePHPCRAdminBundle\Form\Extension;

use Sonata\CoreBundle\Form\Type\CollectionType as DeprecatedCollectionType;
use Sonata\DoctrinePHPCRAdminBundle\Form\Listener\CollectionOrderListener;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvents;

/**
* @deprecated since sonata-project/doctrine-phpcr-admin-bundle 2.x
* NEXT_MAJOR: Remove this class when replace SonataCoreBundle by SonataFormExtension
* Extend the sonata collection type to sort the collection so the reordering
* is automatically persisted in phpcr-odm.
*/
class LegacyCollectionTypeExtension extends AbstractTypeExtension
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
if ('doctrine_phpcr' !== $options['sonata_field_description']->getAdmin()->getManagerType() || !$options['sonata_field_description']->getOption('sortable')) {
return;
}
$listener = new CollectionOrderListener($options['sonata_field_description']->getName());
$builder->addEventListener(FormEvents::SUBMIT, [$listener, 'onSubmit']);
}

/**
* {@inheritdoc}
*/
public function getExtendedType()
{
return self::getExtendedTypes()[0];
}

/**
* {@inheritdoc}
*/
public static function getExtendedTypes()
{
return [
DeprecatedCollectionType::class,
];
}
}
2 changes: 1 addition & 1 deletion src/Guesser/FilterTypeGuesser.php
Expand Up @@ -19,11 +19,11 @@
use Doctrine\ODM\PHPCR\Mapping\MappingException;
use Sonata\AdminBundle\Guesser\TypeGuesserInterface;
use Sonata\AdminBundle\Model\ModelManagerInterface;
use Sonata\CoreBundle\Form\Type\BooleanType;
use Sonata\DoctrinePHPCRAdminBundle\Filter\BooleanFilter;
use Sonata\DoctrinePHPCRAdminBundle\Filter\DateFilter;
use Sonata\DoctrinePHPCRAdminBundle\Filter\NumberFilter;
use Sonata\DoctrinePHPCRAdminBundle\Filter\StringFilter;
use Sonata\Form\Type\BooleanType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Guess\Guess;
Expand Down
4 changes: 2 additions & 2 deletions src/Guesser/TypeGuesser.php
Expand Up @@ -18,8 +18,8 @@
use Doctrine\ODM\PHPCR\Mapping\MappingException;
use Sonata\AdminBundle\Guesser\TypeGuesserInterface;
use Sonata\AdminBundle\Model\ModelManagerInterface;
use Sonata\CoreBundle\Form\Type\BooleanType;
use Sonata\CoreBundle\Form\Type\DatePickerType;
use Sonata\Form\Type\BooleanType;
use Sonata\Form\Type\DatePickerType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Guess\Guess;
Expand Down
6 changes: 5 additions & 1 deletion src/Resources/config/doctrine_phpcr_form_types.xml
Expand Up @@ -10,8 +10,12 @@
<service id="sonata.admin.doctrine_phpcr.form.type.phpcr_odm_tree_manager" class="Sonata\DoctrinePHPCRAdminBundle\Form\Type\TreeManagerType">
<tag name="form.type" alias="doctrine_phpcr_odm_tree_manager"/>
</service>
<service id="sonata.admin.doctrine_phpcr.form.collection_type_extension" class="Sonata\DoctrinePHPCRAdminBundle\Form\Extension\CollectionTypeExtension" public="true">
<service id="sonata.admin.doctrine_phpcr.form.collection_type_extension_legacy" class="Sonata\DoctrinePHPCRAdminBundle\Form\Extension\LegacyCollectionTypeExtension" public="true">
<tag name="form.type_extension" extended-type="Sonata\CoreBundle\Form\Type\CollectionType" alias="sonata_type_collection"/>
<deprecated>The "%service_id%" service is deprecated since sonata-project/doctrine-phpcr-admin-bundle 2.x</deprecated>
</service>
<service id="sonata.admin.doctrine_phpcr.form.collection_type_extension" class="Sonata\DoctrinePHPCRAdminBundle\Form\Extension\CollectionTypeExtension" public="true">
<tag name="form.type_extension" extended-type="Sonata\Form\Type\CollectionType" alias="sonata_type_collection"/>
</service>
</services>
</container>
8 changes: 4 additions & 4 deletions tests/Fixtures/App/Admin/ContentAdmin.php
Expand Up @@ -20,14 +20,14 @@
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Form\Type\ModelType;
use Sonata\AdminBundle\Show\ShowMapper;
use Sonata\DoctrinePHPCRAdminBundle\Admin\Admin;
use Sonata\DoctrinePHPCRAdminBundle\Filter\NodeNameFilter;
use Sonata\DoctrinePHPCRAdminBundle\Filter\StringFilter;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Sonata\CoreBundle\Form\Type\CollectionType;
use Sonata\DoctrinePHPCRAdminBundle\Admin\Admin;
use Sonata\DoctrinePHPCRAdminBundle\Tests\Fixtures\App\Document\Content;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Sonata\Form\Type\CollectionType;
use Symfony\Cmf\Bundle\TreeBrowserBundle\Form\Type\TreeSelectType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\TextType;

/**
* @author Maximilian Berghoff <Maximilian.Berghoff@mayflower.de>
Expand Down
1 change: 1 addition & 0 deletions tests/Fixtures/App/config/bundles.php
Expand Up @@ -17,6 +17,7 @@
Knp\Bundle\MenuBundle\KnpMenuBundle::class => ['all' => true],
Sonata\AdminBundle\SonataAdminBundle::class => ['all' => true],
Sonata\CoreBundle\SonataCoreBundle::class => ['all' => true],
Sonata\Doctrine\Bridge\Symfony\Bundle\SonataDoctrineBundle::class => ['all' => true],
Sonata\BlockBundle\SonataBlockBundle::class => ['all' => true],
Sonata\DoctrinePHPCRAdminBundle\SonataDoctrinePHPCRAdminBundle::class => ['all' => true],
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Filter/BooleanFilterTest.php
Expand Up @@ -13,8 +13,8 @@

namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Unit\Filter;

use Sonata\CoreBundle\Form\Type\BooleanType;
use Sonata\DoctrinePHPCRAdminBundle\Filter\BooleanFilter;
use Sonata\Form\Type\BooleanType;

class BooleanFilterTest extends BaseTestCase
{
Expand Down

0 comments on commit cde9f9a

Please sign in to comment.