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

Commit

Permalink
Merge ddcd98a into 5b34872
Browse files Browse the repository at this point in the history
  • Loading branch information
sad270 committed Sep 9, 2019
2 parents 5b34872 + ddcd98a commit d93d587
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 12 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -49,7 +49,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.13",
"symfony-cmf/resource": "^1.0",
"symfony-cmf/resource-bundle": "^1.0",
"symfony-cmf/testing": "^2.1.11",
Expand Down
2 changes: 2 additions & 0 deletions src/Builder/FormContractor.php
Expand Up @@ -149,6 +149,8 @@ public function getDefaultOptions($type, FieldDescriptionInterface $fieldDescrip

break;
case 'Sonata\CoreBundle\Form\Type\CollectionType':
case 'sonata_type_collection_legacy':
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
15 changes: 14 additions & 1 deletion src/Form/Extension/CollectionTypeExtension.php
Expand Up @@ -13,7 +13,9 @@

namespace Sonata\DoctrinePHPCRAdminBundle\Form\Extension;

use Sonata\CoreBundle\Form\Type\CollectionType as DeprecatedCollectionType;
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 +43,17 @@ public function buildForm(FormBuilderInterface $builder, array $options)
*/
public function getExtendedType()
{
return 'Sonata\CoreBundle\Form\Type\CollectionType';
return self::getExtendedTypes()[0];
}

/**
* {@inheritdoc}
*/
public static function getExtendedTypes()
{
return [
CollectionType::class,
DeprecatedCollectionType::class,
];
}
}
30 changes: 30 additions & 0 deletions src/Form/Extension/DeprecatedCollectionTypeExtension.php
@@ -0,0 +1,30 @@
<?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;

/**
* @deprecated
* Extend the sonata collection type to sort the collection so the reordering
* is automatically persisted in phpcr-odm.
*/
class DeprecatedCollectionTypeExtension extends CollectionTypeExtension
{
/**
* {@inheritdoc}
*/
public function getExtendedType()
{
return self::getExtendedTypes()[1];
}
}
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
5 changes: 4 additions & 1 deletion src/Resources/config/doctrine_phpcr_form_types.xml
Expand Up @@ -10,8 +10,11 @@
<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\DeprecatedCollectionTypeExtension" public="true">
<tag name="form.type_extension" extended-type="Sonata\CoreBundle\Form\Type\CollectionType" alias="sonata_type_collection"/>
</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
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 d93d587

Please sign in to comment.