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 Jan 10, 2020
2 parents c4230c3 + 113365b commit 3ebb494
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 63 deletions.
36 changes: 21 additions & 15 deletions composer.json
Expand Up @@ -24,29 +24,32 @@
"php": "^7.1",
"doctrine/phpcr-bundle": "^1.3 || ^2.0",
"doctrine/phpcr-odm": "^1.4.2 || ^2.0",
"sonata-project/admin-bundle": "^3.30.1",
"sonata-project/block-bundle": "^3.11",
"sonata-project/admin-bundle": "^3.56.1",
"sonata-project/block-bundle": "^3.18.3",
"symfony-cmf/resource-rest-bundle": "^1.0.1",
"symfony-cmf/tree-browser-bundle": "^2.0",
"symfony/config": "^2.8 || ^3.2 || ^4.0",
"symfony/dependency-injection": "^2.8 || ^3.2 || ^4.0",
"symfony/finder": "^2.8 || ^3.2 || ^4.0",
"symfony/form": "^2.8.8 || ^3.2 || ^4.0",
"symfony/framework-bundle": "^2.8.18 || ^3.2.5 || ^4.0",
"symfony/http-foundation": "^2.8 || ^3.2 || ^4.0",
"symfony/http-kernel": "^2.8 || ^3.2 || ^4.0",
"symfony/options-resolver": "^2.8 || ^3.2 || ^4.0",
"symfony/property-access": "^2.8 || ^3.2 || ^4.0"
"symfony/config": "^3.4.36 || ^4.2",
"symfony/dependency-injection": "^3.4.36 || ^4.2",
"symfony/finder": "^3.4.36 || ^4.2",
"symfony/form": "^3.4.36 || ^4.2",
"symfony/framework-bundle": "^3.4.36 || ^4.2",
"symfony/http-foundation": "^3.4.36 || ^4.2",
"symfony/http-kernel": "^3.4.36 || ^4.2",
"symfony/options-resolver": "^3.4.36 || ^4.2",
"symfony/property-access": "^3.4.36 || ^4.2"
},
"conflict": {
"jms/serializer-bundle": "<2.3.1",
"sonata-project/doctrine-extensions": "<=1.3.0"
},
"provide": {
"sonata-project/admin-bundle-persistency-layer": "1.0.0"
},
"require-dev": {
"dantleech/glob-finder": "^1.0",
"jackalope/jackalope-jackrabbit": "^1.3",
"doctrine/doctrine-bundle": "^1.12.6 || ^2.0",
"jackalope/jackalope-doctrine-dbal": "^1.4.1",
"jackalope/jackalope-jackrabbit": "^1.3.2",
"matthiasnoback/symfony-dependency-injection-test": "^3.1",
"phpcr/phpcr": "^2.1",
"phpcr/phpcr-utils": "^1.4.0",
Expand All @@ -55,11 +58,14 @@
"sonata-project/core-bundle": "^3.14",
"symfony-cmf/resource": "^1.0",
"symfony-cmf/resource-bundle": "^1.0",
"symfony-cmf/testing": "^2.1.12",
"symfony-cmf/testing": "^3.0.0",
"symfony/css-selector": "^3.4.22 || ^4.1 || ^5.0",
"symfony/doctrine-bridge": "^3.4.22 || ^4.1 || ^5.0",
"symfony/monolog-bundle": "^3.5",
"symfony/phpunit-bridge": "^4.3.7",
"symfony/routing": "^2.8 || ^3.2 || ^4.0",
"symfony/routing": "^3.4.36 || ^4.2",
"symfony/security-acl": "^2.8 || ^3.0",
"symfony/validator": "^2.8.16 || ^3.1.9 || ^4.0.0"
"symfony/validator": "^3.4 || ^4.2"
},
"config": {
"sort-packages": true
Expand Down
5 changes: 0 additions & 5 deletions docs/reference/document_tree.rst
Expand Up @@ -250,11 +250,6 @@ like this:
],
));
.. note::

To use the configuration for Symfony < 3.4 you should use the single colon (:) notation to define controller
actions: ``sonata.admin.doctrine_phpcr.tree_controller:treeAction`` – `jsTree`_

.. _`CmfTreeBrowserBundle`: http://symfony.com/doc/master/cmf/bundles/tree_browser/introduction.html
.. _`cmf-sandbox configuration`: https://github.com/symfony-cmf/cmf-sandbox/blob/master/app/config/config.yml
.. _`jsTree`: http://www.jstree.com/documentation
Expand Down
25 changes: 16 additions & 9 deletions src/Builder/FormContractor.php
Expand Up @@ -17,6 +17,13 @@
use Sonata\AdminBundle\Admin\AdminInterface;
use Sonata\AdminBundle\Admin\FieldDescriptionInterface;
use Sonata\AdminBundle\Builder\FormContractorInterface;
use Sonata\AdminBundle\Form\Type\AdminType;
use Sonata\AdminBundle\Form\Type\ModelType;
use Sonata\AdminBundle\Form\Type\ModelTypeList;
use Sonata\CoreBundle\Form\Type\CollectionType as DeprecatedCollectionType;
use Sonata\DoctrinePHPCRAdminBundle\Form\Type\TreeModelType;
use Sonata\Form\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\FormFactoryInterface;

class FormContractor implements FormContractorInterface
Expand All @@ -42,7 +49,7 @@ public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInter
{
$metadata = null;
if ($admin->getModelManager()->hasMetadata($admin->getClass())) {
/** @var \Doctrine\ODM\PHPCR\Mapping\ClassMetadata $metadata */
/** @var ClassMetadata $metadata */
$metadata = $admin->getModelManager()->getMetadata($admin->getClass());

// set the default field mapping
Expand Down Expand Up @@ -96,7 +103,7 @@ public function getFormBuilder($name, array $options = [])
{
return $this->getFormFactory()->createNamedBuilder(
$name,
'Symfony\Component\Form\Extension\Core\Type\FormType',
FormType::class,
null,
$options);
}
Expand All @@ -113,15 +120,15 @@ public function getDefaultOptions($type, FieldDescriptionInterface $fieldDescrip
$options['sonata_field_description'] = $fieldDescription;

switch ($type) {
case 'Sonata\DoctrinePHPCRAdminBundle\Form\Type\TreeModelType':
case TreeModelType::class:
case 'doctrine_phpcr_odm_tree':
$options['class'] = $fieldDescription->getTargetEntity();
$options['model_manager'] = $fieldDescription->getAdmin()->getModelManager();

break;
case 'Sonata\AdminBundle\Form\Type\ModelType':
case ModelType::class:
case 'sonata_type_model':
case 'Sonata\AdminBundle\Form\Type\ModelTypeList':
case ModelTypeList::class:
case 'sonata_type_model_list':
if ('child' !== $fieldDescription->getMappingType() && !$fieldDescription->getTargetEntity()) {
throw new \LogicException(sprintf(
Expand All @@ -135,7 +142,7 @@ public function getDefaultOptions($type, FieldDescriptionInterface $fieldDescrip
$options['model_manager'] = $fieldDescription->getAdmin()->getModelManager();

break;
case 'Sonata\AdminBundle\Form\Type\AdminType':
case AdminType::class:
case 'sonata_type_admin':
if (!$fieldDescription->getAssociationAdmin()) {
throw $this->getAssociationAdminException($fieldDescription);
Expand All @@ -145,19 +152,19 @@ public function getDefaultOptions($type, FieldDescriptionInterface $fieldDescrip
$fieldDescription->setOption('edit', $fieldDescription->getOption('edit', 'admin'));

break;
case 'Sonata\CoreBundle\Form\Type\CollectionType':
case DeprecatedCollectionType::class:
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 CollectionType::class:
case 'sonata_type_collection':
if (!$fieldDescription->getAssociationAdmin()) {
throw $this->getAssociationAdminException($fieldDescription);
}

$options['type'] = 'Sonata\AdminBundle\Form\Type\AdminType';
$options['type'] = AdminType::class;
$options['modifiable'] = true;
$options['type_options'] = [
'sonata_field_description' => $fieldDescription,
Expand Down
8 changes: 2 additions & 6 deletions src/Form/Type/ChoiceFieldMaskType.php
Expand Up @@ -41,9 +41,7 @@ public function buildView(FormView $view, FormInterface $form, array $options):
}

/**
* {@inheritdoc}
*
* @todo Remove when Symfony <2.8 is no longer supported
* NEXT_MAJOR: remove this method.
*/
public function setDefaultOptions(OptionsResolverInterface $resolver): void
{
Expand All @@ -69,9 +67,7 @@ public function getParent()
}

/**
* {@inheritdoc}
*
* @todo Remove when Symfony <2.8 is no longer supported
* NEXT_MAJOR: remove this method.
*/
public function getName()
{
Expand Down
4 changes: 1 addition & 3 deletions src/Form/Type/Filter/ChoiceType.php
Expand Up @@ -22,9 +22,7 @@ class ChoiceType extends BaseChoiceType
public const TYPE_CONTAINS_WORDS = 4;

/**
* {@inheritdoc}
*
* @todo Remove when Symfony <2.8 is no longer supported
* NEXT_MAJOR: remove this method.
*/
public function getName()
{
Expand Down
17 changes: 4 additions & 13 deletions src/Form/Type/TreeManagerType.php
Expand Up @@ -34,9 +34,7 @@ public function buildView(FormView $view, FormInterface $form, array $options):
}

/**
* {@inheritdoc}
*
* @todo Remove when Symfony <2.8 is no longer supported
* NEXT_MAJOR: remove this method.
*/
public function setDefaultOptions(OptionsResolverInterface $resolver): void
{
Expand All @@ -50,13 +48,8 @@ public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setRequired(['root']);

if (method_exists($resolver, 'setDefined')) {
// The new OptionsResolver API
$resolver->setDefined(['create_in_overlay', 'edit_in_overlay', 'delete_in_overlay']);
} else {
// To keep compatibility with old Symfony <2.6 API
$resolver->setOptional(['create_in_overlay', 'edit_in_overlay', 'delete_in_overlay']);
}
// The new OptionsResolver API
$resolver->setDefined(['create_in_overlay', 'edit_in_overlay', 'delete_in_overlay']);

$resolver->setDefaults([
'create_in_overlay' => true,
Expand All @@ -66,9 +59,7 @@ public function configureOptions(OptionsResolver $resolver): void
}

/**
* {@inheritdoc}
*
* @todo Remove when Symfony <2.8 is no longer supported
* NEXT_MAJOR: remove this method.
*/
public function getName()
{
Expand Down
8 changes: 2 additions & 6 deletions src/Form/Type/TreeModelType.php
Expand Up @@ -58,9 +58,7 @@ public function buildView(FormView $view, FormInterface $form, array $options):
}

/**
* {@inheritdoc}
*
* @todo Remove when Symfony <2.8 is no longer supported
* NEXT_MAJOR: remove this method.
*/
public function setDefaultOptions(OptionsResolverInterface $resolver): void
{
Expand Down Expand Up @@ -98,9 +96,7 @@ public function configureOptions(OptionsResolver $resolver): void
}

/**
* {@inheritdoc}
*
* @todo Remove when Symfony <2.8 is no longer supported
* NEXT_MAJOR: remove this method.
*/
public function getName()
{
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/views/Form/form_admin_fields.html.twig
Expand Up @@ -147,7 +147,7 @@ file that was distributed with this source code.
or sonata_admin.field_description.mappingtype == 'referrers' %}
{{ block('sonata_admin_phpcr_one_to_many_widget') }}
{% else %}
INVALID MODE : {{ id }} - type : sonata_type_collection - mapping : {{ sonata_admin.field_description.mappingtype }}
INVALID MODE : {{ id }} - type : CollectionType - mapping : {{ sonata_admin.field_description.mappingtype }}
{% endif %}
{% endblock %}

Expand All @@ -159,7 +159,7 @@ file that was distributed with this source code.
%}
{{ block('sonata_admin_phpcr_one_to_many_widget') }}
{% else %}
INVALID MODE : {{ id }} - type : sonata_type_collection - mapping : {{ sonata_admin.field_description.mappingtype }}
INVALID MODE : {{ id }} - type : CollectionType - mapping : {{ sonata_admin.field_description.mappingtype }}
{% endif %}
{% endblock %}

Expand Down
12 changes: 8 additions & 4 deletions src/SonataDoctrinePHPCRAdminBundle.php
Expand Up @@ -17,6 +17,10 @@
use Sonata\DoctrinePHPCRAdminBundle\DependencyInjection\Compiler\AddGuesserCompilerPass;
use Sonata\DoctrinePHPCRAdminBundle\DependencyInjection\Compiler\AddTemplatesCompilerPass;
use Sonata\DoctrinePHPCRAdminBundle\DependencyInjection\Compiler\AddTreeBrowserAssetsPass;
use Sonata\DoctrinePHPCRAdminBundle\Form\Type\ChoiceFieldMaskType;
use Sonata\DoctrinePHPCRAdminBundle\Form\Type\Filter\ChoiceType;
use Sonata\DoctrinePHPCRAdminBundle\Form\Type\TreeManagerType;
use Sonata\DoctrinePHPCRAdminBundle\Form\Type\TreeModelType;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;

Expand All @@ -42,10 +46,10 @@ public function boot(): void
private function registerFormMapping(): void
{
FormHelper::registerFormTypeMapping([
'doctrine_phpcr_type_filter_choice' => 'Sonata\DoctrinePHPCRAdminBundle\Form\Type\Filter\ChoiceType',
'choice_field_mask' => 'Sonata\DoctrinePHPCRAdminBundle\Form\Type\ChoiceFieldMaskType',
'doctrine_phpcr_odm_tree_manager' => 'Sonata\DoctrinePHPCRAdminBundle\Form\Type\TreeManagerType',
'doctrine_phpcr_odm_tree' => 'Sonata\DoctrinePHPCRAdminBundle\Form\Type\TreeModelType',
'doctrine_phpcr_type_filter_choice' => ChoiceType::class,
'choice_field_mask' => ChoiceFieldMaskType::class,
'doctrine_phpcr_odm_tree_manager' => TreeManagerType::class,
'doctrine_phpcr_odm_tree' => TreeModelType::class,
]);
}
}
7 changes: 7 additions & 0 deletions tests/Fixtures/App/config/config.php
Expand Up @@ -11,7 +11,14 @@
* file that was distributed with this source code.
*/

use Symfony\Component\HttpKernel\Kernel;

$container->setParameter('cmf_testing.bundle_fqn', 'Sonata\DoctrinePHPCRAdminBundle');
$loader->import(CMF_TEST_CONFIG_DIR.'/default.php');
$loader->import(__DIR__.'/sonata_phpcr_admin.yml');
$loader->import(CMF_TEST_CONFIG_DIR.'/phpcr_odm.php');
if (version_compare(Kernel::VERSION, '4.2', '<')) {
$container->loadFromExtension('framework', [
'fragments' => ['enabled' => true],
]);
}

0 comments on commit 3ebb494

Please sign in to comment.