Commit Graph

8 Commits

Author SHA1 Message Date
Fabien Potencier 5b38d74128 feature #15079 [Form] Deprecated FormTypeInterface::getName() and passing of type instances (webmozart)
This PR was merged into the 2.8 branch.

Discussion
----------

[Form] Deprecated FormTypeInterface::getName() and passing of type instances

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

#### Type Names

This PR deprecates the definition of the `getName()` method of form types. See #15008 for a more detailed description.

Before:

```php
class MyType extends AbstractType
{
    public function getName()
    {
        return 'mytype';
    }

    // ...
}
```

After:

```php
class MyType extends AbstractType
{
    // ...
}
```

You should always reference other types by their fully-qualified class names. Thanks to PHP 5.5, that's easy:

Before:

```php
$form = $this->createFormBuilder()
    ->add('name', 'text')
    ->add('age', 'integer')
    ->getForm();
```

After:

```php
$form = $this->createFormBuilder()
    ->add('name', TextType::class)
    ->add('age', IntegerType::class)
    ->getForm();
```

#### Type Instances

Furthermore, passing of type instances is deprecated.

Before:

```php
$form = $this->createForm(new AuthorType());
```

After:

```php
$form = $this->createForm(AuthorType::class);
```

#### DIC Aliases

When registering a type in the DIC, you should omit the "alias" attribute now.

Before:

```xml
<service id="my.type" class="Vendor\Type\MyType">
    <tag name="form.type" alias="mytype" />
    <argument type="service" id="some.service.id" />
</service>
```

After:

```xml
<service id="my.type" class="Vendor\Type\MyType">
    <tag name="form.type" />
    <argument type="service" id="some.service.id" />
</service>
```

Types without dependencies don't need to be registered in the DIC as they can be instantiated right away.

#### Template Block Prefixes

By default, the class name of the type in underscore notation minus "Type" suffix is used as Twig template block prefix (e.g. `UserProfileType` => `user_profile_*`). If you want to customize that, overwrite the new `getBlockPrefix()` method in your type:

```php
class UserProfileType extends AbstractType
{
    public function getBlockPrefix()
    {
        return 'profile';
    }

    // ...
}
```

Commits
-------

3d9e5de [Form] Deprecated FormTypeInterface::getName() and passing of type instances
2015-08-01 08:44:19 +02:00
Fabien Potencier ce5363aee0 feature #15372 [FrameworkBundle] Change the default value of cookie_httponly (jderusse)
This PR was merged into the 2.8 branch.

Discussion
----------

[FrameworkBundle] Change the default value of cookie_httponly

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | yes
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #15303
| License       | MIT
| Doc PR        | symfony/symfony-docs#5561

Commits
-------

a7bef1e Change the default value of cookie_httponly to fix #15303
2015-08-01 08:15:28 +02:00
Javier Eguiluz 9df0f8b4b8 Added some upgrade notes about the new toolbar design 2015-07-31 12:12:25 +02:00
Jérémy Derussé a7bef1eb2d Change the default value of cookie_httponly to fix #15303 2015-07-28 13:20:34 +02:00
Bernhard Schussek 3d9e5de2b9 [Form] Deprecated FormTypeInterface::getName() and passing of type instances 2015-07-02 10:02:46 +02:00
Diego Saint Esteben 6c4a676d09 Add "shared" flag and deprecate scopes concept 2015-06-24 12:32:32 -03:00
Bernhard Schussek 6c554c6c1a [Form] Deprecated "cascade_validation" 2015-06-17 20:03:11 +02:00
Abdellatif Ait boudad 2869a32cf1 [Translator] deprecate getMessages in favor of getCatalogue. 2015-05-06 09:17:03 +00:00