Skip to content

[3.0] Clean Form, Validator, DowCrawler and some more #16075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 2, 2015

Conversation

nicolas-grekas
Copy link
Member

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

@nicolas-grekas nicolas-grekas force-pushed the master-clean branch 2 times, most recently from fa56ecd to da438fa Compare October 2, 2015 14:06
@@ -61,36 +61,12 @@ public function createForProperty($class, $property, $data = null, array $option
*/
public function createBuilder($type = 'Symfony\Component\Form\Extension\Core\Type\FormType', $data = null, array $options = array())
{
$name = null;
$typeName = null;

if ($type instanceof ResolvedFormTypeInterface) {
Copy link
Contributor

Choose a reason for hiding this comment

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

getBlockPrefix must be added to ResolvedFormTypeInterface

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure we actually need to keep support for ResolvedFormTypeInterface in the factory. it is not supported according to FormFactoryInterface

Copy link
Contributor

Choose a reason for hiding this comment

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

I think there is a bug in the current implementation. createBuilder has logic to handle ResolvedFormTypeInterface, but it then calls createNamedBuilder which will throw an exception as it requires a string as the type.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, it must be removed. It was deprecated in 2.8: https://github.com/symfony/symfony/blob/2.8/src/Symfony/Component/Form/FormFactory.php#L114
So it must be removed from this method as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Form/FormFactoryInterface.php must be updated as well as it still says string|FormTypeInterface $type

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated, can you please review again?

@nicolas-grekas nicolas-grekas force-pushed the master-clean branch 2 times, most recently from f2d71b8 to 9d47437 Compare October 2, 2015 14:29
* @param string|FormTypeInterface $type The type of the form
* @param mixed $data The initial data
* @param array $options The options
* @param string $type The type of the form
Copy link
Contributor

Choose a reason for hiding this comment

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

there are more of it in the interface

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

/**
* @param ValidatorInterface $validator
* @param ViolationMapperInterface $violationMapper
*/
Copy link

Choose a reason for hiding this comment

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

May I know what is the reason of removing the docblock comments ?

Copy link
Member Author

Choose a reason for hiding this comment

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

they provide no value at all, this is just an exact repetition of the method signature

Copy link

Choose a reason for hiding this comment

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

ok, thanks. I wonder whether this have any impact on the sami / phpdoc .

@Tobion
Copy link
Contributor

Tobion commented Oct 2, 2015

@nicolas-grekas
Copy link
Member Author

Removed

@Tobion
Copy link
Contributor

Tobion commented Oct 2, 2015

The choice_list option must be removed still I think.

@nicolas-grekas
Copy link
Member Author

@Tobion I agree with you, but this is more tricky and could be left for an other PR.
I added a few more removals btw.

@nicolas-grekas nicolas-grekas changed the title [3.0] Cleaning Form and Validator a bit more [3.0] Cleaning Form, Validator and some more Oct 2, 2015
@fabpot
Copy link
Member

fabpot commented Oct 2, 2015

The choice_list removal should be done as its own PR.

@@ -846,136 +846,6 @@ public static function xpathLiteral($s)
}

/**
* @deprecated Using the SplObjectStorage API on the Crawler is deprecated as of 2.8 and will be removed in 3.0.
*/
public function attach($object, $data = null)
Copy link
Contributor

Choose a reason for hiding this comment

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

removing this without actually removing extends \SplObjectStorage makes no sense

@Tobion
Copy link
Contributor

Tobion commented Oct 2, 2015

Apart from the changes in Crawler 👍

@nicolas-grekas
Copy link
Member Author

Crawler updated

@nicolas-grekas nicolas-grekas changed the title [3.0] Cleaning Form, Validator and some more [3.0] Clean Form, Validator, DowCrawler and some more Oct 2, 2015
@@ -38,12 +38,6 @@ class ExceptionHandler

public function __construct($debug = true, $charset = null, $fileLinkFormat = null)
{
if (false !== strpos($charset, '%')) {
// Swap $charset and $fileLinkFormat for BC reasons
Copy link
Member Author

Choose a reason for hiding this comment

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

See #16085

@fabpot
Copy link
Member

fabpot commented Oct 2, 2015

Thank you @nicolas-grekas.

@fabpot fabpot merged commit abca2d6 into symfony:master Oct 2, 2015
fabpot added a commit that referenced this pull request Oct 2, 2015
…(nicolas-grekas)

This PR was merged into the 3.0-dev branch.

Discussion
----------

[3.0] Clean Form, Validator, DowCrawler and some more

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Commits
-------

abca2d6 [3.0] Clean Form, Validator, DowCrawler and some more
fabpot added a commit that referenced this pull request Oct 3, 2015
This PR was merged into the 2.8 branch.

Discussion
----------

Add a few additional tests for the Crawler

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

While looking at the update of the Crawler in #16075, I spotted a few mistakes. But these were cases not covered by the testsuite. This is adding tests for these cases in the 2.8 branch (they could be added in 2.3 eventually though).

Commits
-------

528d3bd Add a few additional tests for the Crawler
fabpot added a commit that referenced this pull request Oct 3, 2015
This PR was merged into the 3.0-dev branch.

Discussion
----------

Fix the crawler refactoring

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

This fixes a few mistakes I spotted in #16075 for the DomCrawler component.

Regression tests are added separately in #16093 to be included in older branches too.

Commits
-------

d128735 Fix the crawler refactoring
@fabpot fabpot mentioned this pull request Nov 16, 2015
@renatomefi
Copy link
Contributor

Hello @nicolas-grekas
I see you removed the support for createForm using objects:
abca2d6#diff-5c1348d69be32426ff20446c9e812365R64

How can I create forms which comes from a service for instance?

@stof
Copy link
Member

stof commented Dec 16, 2015

@renatomefidf defining form types as service never required passing the instance to createForm. If you are passing an instance here, it means you are not using your form type as a service as far as the Form component is concerned.
When the form type is registered as a service, using it only involves using its name (see how you use the Symfony core types: they are defined as services)

@renatomefi
Copy link
Contributor

Thank you @stof
Its actually not a problem I'm facing, but a question in here:
http://stackoverflow.com/questions/33451498/symfony-3-define-form-as-a-service

Thanks again for helping and making it clearer!

@stof
Copy link
Member

stof commented Dec 16, 2015

OK, I answered on SO itself

@PaddyLock
Copy link

@stof I am trying to do the same as @renatomefidf But I can't get it to work. Should I be using the form name defined in the form class within getBlockPrefix(), or the forms service name or the name defined in the service definition within
tags: - {name: 'form.my_name'}

I have tried with

$this->createForm('form.my_name', $entity);
$this->createForm('my_form_service_name', $entity);
$this->createForm(MyFormType::class, $entity);

The last one uses the form class but not the form as a service, which is what I need.

Thanks

@xabbuh
Copy link
Member

xabbuh commented Feb 12, 2016

@PaddyLock The tag name to add a form type service is form.type. But please use one of the support channels if you need further helper. Thank you!

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

Successfully merging this pull request may close these issues.

9 participants