minor #16749 [Form] Added getBlockPrefix() to ResolvedFormTypeInterface (webmozart)
This PR was merged into the 3.0-dev branch.
Discussion
----------
[Form] Added getBlockPrefix() to ResolvedFormTypeInterface
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
This is the follow-up PR to #16724.
If you call `$form->getConfig()->getType()`, all the methods of FormType should be usable. In that sense, ResolvedFormType is the developer-facing version of FormType.
It is true that the same could be achieved with `getInnerType()`, but that method should be used in edge cases only as it clutters the code and makes it confusing to read:
```php
$blockPrefix = $form->getConfig()->getType()->getInnerType()->getBlockPrefix();
```
Commits
-------
7e89345
[Form] Added getBlockPrefix() to ResolvedFormTypeInterface
This commit is contained in:
commit
bcfacac1e1
@ -43,20 +43,12 @@ class ResolvedTypeDataCollectorProxy implements ResolvedFormTypeInterface
|
|||||||
$this->dataCollector = $dataCollector;
|
$this->dataCollector = $dataCollector;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getName()
|
|
||||||
{
|
|
||||||
return $this->proxiedType->getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getBlockPrefix()
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return method_exists($this->proxiedType, 'getBlockPrefix') ? $this->proxiedType->getBlockPrefix() : $this->getName();
|
return $this->proxiedType->getBlockPrefix();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,9 +56,7 @@ class ResolvedFormType implements ResolvedFormTypeInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the prefix of the template block name for this type.
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @return string The prefix of the template block name
|
|
||||||
*/
|
*/
|
||||||
public function getBlockPrefix()
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
|
@ -20,6 +20,13 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
|||||||
*/
|
*/
|
||||||
interface ResolvedFormTypeInterface
|
interface ResolvedFormTypeInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Returns the prefix of the template block name for this type.
|
||||||
|
*
|
||||||
|
* @return string The prefix of the template block name
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the parent type.
|
* Returns the parent type.
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user