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:
Tobias Schultze 2015-11-29 23:04:13 +01:00
commit bcfacac1e1
3 changed files with 9 additions and 12 deletions

View File

@ -43,20 +43,12 @@ class ResolvedTypeDataCollectorProxy implements ResolvedFormTypeInterface
$this->dataCollector = $dataCollector;
}
/**
* {@inheritdoc}
*/
public function getName()
{
return $this->proxiedType->getName();
}
/**
* {@inheritdoc}
*/
public function getBlockPrefix()
{
return method_exists($this->proxiedType, 'getBlockPrefix') ? $this->proxiedType->getBlockPrefix() : $this->getName();
return $this->proxiedType->getBlockPrefix();
}
/**

View File

@ -56,9 +56,7 @@ class ResolvedFormType implements ResolvedFormTypeInterface
}
/**
* Returns the prefix of the template block name for this type.
*
* @return string The prefix of the template block name
* {@inheritdoc}
*/
public function getBlockPrefix()
{

View File

@ -20,6 +20,13 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
*/
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.
*