Skip to content

Add support for FQCN form type referencing to FormContractor#196

Merged
core23 merged 1 commit intosonata-project:3.xfrom
pascal-hofmann:3.x
Dec 29, 2016
Merged

Add support for FQCN form type referencing to FormContractor#196
core23 merged 1 commit intosonata-project:3.xfrom
pascal-hofmann:3.x

Conversation

@pascal-hofmann
Copy link
Contributor

@pascal-hofmann pascal-hofmann commented Dec 27, 2016

I am targetting this branch, because this is a bugfix that allows using the new FQCN form type references (i.e. ModelType::class) instead of referencing by type name (i.e. 'sonata_type_model').

Closes sonata-project/SonataAdminBundle#3976 and /pull/178

Changelog

### Fixed
- Fix `FormContractor::getDefaultOptions` not checking against form types FQCNs

To do

  • Update the tests

Subject

FormContractor::getDefaultOptions didn't check against form types FQCNs, causing the default options not to be set when using the Symfony 3 way:

$formMapper->add('foo', ModelType::class);

See related admin-bundle issue at sonata-project/SonataAdminBundle#3976

@pascal-hofmann pascal-hofmann force-pushed the 3.x branch 2 times, most recently from 4bbb4cb to e41f0e0 Compare December 28, 2016 08:59
@pascal-hofmann
Copy link
Contributor Author

I've added tests and changed comparison of form types. Comparison is now done like in SonataDoctrineORMAdminBundle.

@greg0ire
Copy link
Contributor

Nice coverage increase! Please fix the failing test though

@pascal-hofmann
Copy link
Contributor Author

For fixed test case see my other PR. The failing test is not caused by my changes, so I made a separate PR. Will rebase this one when the other one is merged.

@greg0ire
Copy link
Contributor

Perfect

@pascal-hofmann
Copy link
Contributor Author

Rebased on latest 3.x. Tests should work now.

@pascal-hofmann
Copy link
Contributor Author

Would be great to have this merged! is merging done by SonataCI automatically?

use Sonata\DoctrineMongoDBAdminBundle\Builder\FormContractor;
use Symfony\Component\Form\FormFactoryInterface;

final class FormContractorTest extends \PHPUnit_Framework_TestCase
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason to make this final, it's just an internal test class

Copy link
Contributor Author

@pascal-hofmann pascal-hofmann Dec 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@core23 Fixed.

@greg0ire
Copy link
Contributor

The policy is to have 2 approvals before merging


/**
* @var FormFactoryInterface
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why this is protected instead of private?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FormContractor is not final, and subclasses may want to access $formFactory.

Copy link
Member

@core23 core23 Dec 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'may' want.,.

Please make this private until someone really need this

Copy link
Contributor Author

@pascal-hofmann pascal-hofmann Dec 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a reason to limit extensibility. $fieldFactory is protected too. And FormContractor of SonataDoctrineORMBundle has these entities protected too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the other hand, it's accessible through the getter... so no reason to not change it. I'll update the PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@core23 Changed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@pascal-hofmann pascal-hofmann Dec 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood. Valid arguments. Thank you!

Is the updated PR OK for you now @core23?

@core23 core23 merged commit 980c103 into sonata-project:3.x Dec 29, 2016
@core23
Copy link
Member

core23 commented Dec 29, 2016

Thanks @pascal-hofmann

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ModelType class can't be used with the new Symfony way

5 participants