Skip to content

[3.0] [Form] Added the new getBlockPrefix() method to the ResolvedFormTypeInterface #16200

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

Closed
wants to merge 1 commit into from

Conversation

wouterj
Copy link
Member

@wouterj wouterj commented Oct 11, 2015

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

@Tobion
Copy link
Contributor

Tobion commented Oct 11, 2015

The implementations should change the phpdoc to {@inheritdoc}

@stof
Copy link
Member

stof commented Oct 11, 2015

2.8 should trigger a deprecation when your form type does not implement the method though.

@wouterj
Copy link
Member Author

wouterj commented Oct 11, 2015

@stof there is a default implementation of this method in AbstractType (in both 2.8 and 3.0). Do you think it's needed to trigger the deprecation notice in case someone created a type by implementing only the interface? (I think it's a very rare use-case)

/**
* Returns the prefix of the template block name for this type.
*
* The block prefixes default to the underscored short class name with
Copy link
Contributor

Choose a reason for hiding this comment

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

Using singular "The block prefix defaults to" would fit better since this method is about exactly one prefix.

@fabpot
Copy link
Member

fabpot commented Oct 19, 2015

LGTM 👍

@Tobion
Copy link
Contributor

Tobion commented Oct 19, 2015

The implementations should change the phpdoc to {@inheritdoc}

Status: Needs Work

@wouterj
Copy link
Member Author

wouterj commented Oct 21, 2015

Changed PHPdoc to {@inheritdoc} for the implementations and removed a deprecated getName method. Ready to be merged imo

@wouterj
Copy link
Member Author

wouterj commented Oct 21, 2015

Status: Needs review

* Returns the prefix of the template block name for this type.
*
* @return string The prefix of the template block name
* {@inheritdoc}
Copy link
Contributor

Choose a reason for hiding this comment

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

this is wrong as ResolvedFormTypeInterface does not define a getBlockPrefix. So either the method must be added to that interface as well. Or the public method should be removed from ResolvedFormType. I don't see why we need that public method on the resolved type as one can access it easily through getInnerType

Copy link
Member Author

Choose a reason for hiding this comment

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

getName was part of the ResolvedFormTypeInterface: https://github.com/symfony/form/blob/2.8/ResolvedFormTypeInterface.php#L23-L28 I think it makes much sense to make getBlockPrefix part of the interface in 3.0

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 it should be removed. I don't see the point of having this method in the resolved type as it must equal the inner one. So overwriting it makes no sense either.

Copy link
Contributor

Choose a reason for hiding this comment

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

But if we remove it, we should do so in 2.8. @webmozart what is the point of having a getBlockPrefix on the ResolvedFormType?

Copy link
Member

Choose a reason for hiding this comment

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

ping @webmozart

Copy link
Member Author

Choose a reason for hiding this comment

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

let's just merge this as is?

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 we should add the method to ResolvedFormTypeInterface also to respect the LoD. The method is used in https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Form/Extension/Core/Type/BaseType.php#L80.

Copy link
Contributor

Choose a reason for hiding this comment

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

@webmozart why not simply call $type->getInnerType()->getBlockPrefix() there? It seems strange to me to offer two ways to do the same thing.

Copy link
Member

Choose a reason for hiding this comment

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

I agree with @Tobion if that's the only reason to have this method in the interface.

Copy link
Contributor

Choose a reason for hiding this comment

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

My argument can be found in #16749. ResolvedFormType was always supposed to have all methods of FormType. getInnerType() exists for edge cases where you want to know by which actual class a form type is backed.

@fabpot
Copy link
Member

fabpot commented Nov 28, 2015

This one should be finished and merged today or tomorrow.

@wouterj
Copy link
Member Author

wouterj commented Nov 28, 2015

@fabpot the PR itself is finished. Should I split the PR in 2 PRs: One for the FormType and one for the ResolvedFormType? (as the FormType is a no-brainer and has to be merged)

@fabpot
Copy link
Member

fabpot commented Nov 28, 2015

Splitting would be indeed a good way to merge it faster.

@wouterj wouterj changed the title [3.0] [Form] Added the new getBlockPrefix() method to the FormTypeInterface [3.0] [Form] Added the new getBlockPrefix() method to the ResolvedFormTypeInterface Nov 28, 2015
@wouterj
Copy link
Member Author

wouterj commented Nov 28, 2015

@fabpot I created a new PR for the FormTypeInterface: #16724 (which can be merged)

@webmozart
Copy link
Contributor

@fabpot Here's the follow-up: #16749

@webmozart webmozart closed this Nov 29, 2015
@wouterj wouterj deleted the patch-17 branch November 29, 2015 21:42
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.

8 participants