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

Commit

Permalink
Merge 6c320f4 into eec1482
Browse files Browse the repository at this point in the history
  • Loading branch information
franmomu committed Dec 10, 2019
2 parents eec1482 + 6c320f4 commit 249af55
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 58 deletions.
20 changes: 10 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
"sonata-project/block-bundle": "^3.11",
"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": {
"sonata-project/doctrine-extensions": "<=1.3.0"
Expand All @@ -57,7 +57,7 @@
"symfony-cmf/resource-bundle": "^1.0",
"symfony-cmf/testing": "^2.1.12",
"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"
},
"config": {
Expand Down
5 changes: 0 additions & 5 deletions docs/reference/document_tree.rst
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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)
{
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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)
{
Expand All @@ -50,13 +48,8 @@ public function configureOptions(OptionsResolver $resolver)
{
$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)
}

/**
* {@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
Original file line number Diff line number Diff line change
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)
{
Expand Down Expand Up @@ -98,9 +96,7 @@ public function configureOptions(OptionsResolver $resolver)
}

/**
* {@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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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()
private function registerFormMapping()
{
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,
]);
}
}

0 comments on commit 249af55

Please sign in to comment.