Skip to content

Commit ae53c89

Browse files
committed
Merge branch '2.8' into 3.0
Conflicts: cookbook/security/_ircmaxwell_password-compat.rst.inc create_framework/introduction.rst
2 parents f625981 + cf2fb97 commit ae53c89

25 files changed

+162
-188
lines changed

book/doctrine.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -953,8 +953,8 @@ To relate the ``Category`` and ``Product`` entities, start by creating a
953953
products:
954954
targetEntity: Product
955955
mappedBy: category
956-
# don't forget to init the collection in the __construct() method
957-
# of the entity
956+
# Don't forget to initialize the collection in
957+
# the __construct() method of the entity
958958
959959
.. code-block:: xml
960960
@@ -1096,7 +1096,7 @@ table, and ``product.category_id`` column, and new foreign key:
10961096
10971097
.. note::
10981098

1099-
This task should only be really used during development. For a more robust
1099+
This command should only be used during development. For a more robust
11001100
method of systematically updating your production database, read about
11011101
`migrations`_.
11021102

@@ -1187,7 +1187,7 @@ You can also query in the other direction::
11871187
// ...
11881188
}
11891189

1190-
In this case, the same things occurs: you first query out for a single ``Category``
1190+
In this case, the same things occur: you first query out for a single ``Category``
11911191
object, and then Doctrine makes a second query to retrieve the related ``Product``
11921192
objects, but only once/if you ask for them (i.e. when you call ``->getProducts()``).
11931193
The ``$products`` variable is an array of all ``Product`` objects that relate

book/forms.rst

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ Handling Form Submissions
223223

224224
The second job of a form is to translate user-submitted data back to the
225225
properties of an object. To make this happen, the submitted data from the
226-
user must be written into the form. Add the following functionality to your
227-
controller::
226+
user must be written into the Form object. Add the following functionality to
227+
your controller::
228228

229229
// ...
230230
use Symfony\Component\HttpFoundation\Request;
@@ -694,9 +694,14 @@ the documentation for each type.
694694
The most common option is the ``required`` option, which can be applied to
695695
any field. By default, the ``required`` option is set to ``true``, meaning
696696
that HTML5-ready browsers will apply client-side validation if the field
697-
is left blank. If you don't want this behavior, either set the ``required``
698-
option on your field to ``false`` or
699-
:ref:`disable HTML5 validation <book-forms-html5-validation-disable>`.
697+
is left blank. If you don't want this behavior, either
698+
:ref:`disable HTML5 validation <book-forms-html5-validation-disable>`
699+
or set the ``required`` option on your field to ``false``::
700+
701+
->add('dueDate', 'date', array(
702+
'widget' => 'single_text',
703+
'required' => false
704+
))
700705

701706
Also note that setting the ``required`` option to ``true`` will **not**
702707
result in server-side validation to be applied. In other words, if a
@@ -935,7 +940,7 @@ specify it:
935940

936941
Some field types have additional rendering options that can be passed
937942
to the widget. These options are documented with each type, but one common
938-
options is ``attr``, which allows you to modify attributes on the form element.
943+
option is ``attr``, which allows you to modify attributes on the form element.
939944
The following would add the ``task_field`` class to the rendered input text
940945
field:
941946

book/templating.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ First, build a base layout file:
201201
<!DOCTYPE html>
202202
<html>
203203
<head>
204-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
204+
<meta charset="UTF-8">
205205
<title>{% block title %}Test Application{% endblock %}</title>
206206
</head>
207207
<body>
@@ -226,7 +226,7 @@ First, build a base layout file:
226226
<!DOCTYPE html>
227227
<html>
228228
<head>
229-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
229+
<meta charset="UTF-8">
230230
<title><?php $view['slots']->output('title', 'Test Application') ?></title>
231231
</head>
232232
<body>
@@ -311,7 +311,7 @@ output might look like this:
311311
<!DOCTYPE html>
312312
<html>
313313
<head>
314-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
314+
<meta charset="UTF-8">
315315
<title>My cool blog posts</title>
316316
</head>
317317
<body>

contributing/code/patches.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ work:
116116
* ``2.3``, if you are fixing a bug for an existing feature (you may have
117117
to choose a higher branch if the feature you are fixing was introduced
118118
in a later version);
119-
* ``2.8``, if you are adding a new feature which is backward compatible;
120-
* ``master``, if you are adding a new and backward incompatible feature.
119+
* ``master``, if you are adding a new feature.
121120

122121
.. note::
123122

cookbook/assetic/asset_management.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ Starting from Symfony 2.8, Assetic is no longer included by default in the
1111
Symfony Standard Edition. Before using any of its features, install the
1212
AsseticBundle executing this console command in your project:
1313

14-
.. code-block:: bash
14+
.. code-block:: bash
1515
16-
$ composer require symfony/assetic-bundle
16+
$ composer require symfony/assetic-bundle
1717
1818
Then, enable the bundle in the ``AppKernel.php`` file of your Symfony application::
1919

cookbook/form/dynamic_form_modification.rst

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -374,13 +374,15 @@ you need to register it as a service and tag it with :ref:`form.type <dic-tags-f
374374
.. code-block:: php
375375
376376
// app/config/config.php
377-
$definition = new Definition('AppBundle\Form\Type\FriendMessageFormType');
378-
$definition->addTag('form.type');
379-
$container->setDefinition(
380-
'app.form.friend_message',
381-
$definition,
382-
array('security.token_storage')
377+
use Symfony\Component\DependencyInjection\Reference;
378+
379+
$definition = new Definition(
380+
'AppBundle\Form\Type\FriendMessageFormType',
381+
array(new Reference('security.token_storage'))
383382
);
383+
$definition->addTag('form.type');
384+
385+
$container->setDefinition('app.form.friend_message', $definition);
384386
385387
In a controller that extends the :class:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller`
386388
class, you can simply call::

cookbook/form/form_customization.rst

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ directly in the template that's actually rendering the form.
264264

265265
.. code-block:: html+twig
266266

267-
{% extends '::base.html.twig' %}
267+
{% extends 'base.html.twig' %}
268268

269269
{% form_theme form _self %}
270270

@@ -303,7 +303,7 @@ can now re-use the form customization across many templates:
303303

304304
.. code-block:: html+twig
305305

306-
{# app/Resources/views/Form/fields.html.twig #}
306+
{# app/Resources/views/form/fields.html.twig #}
307307
{% block integer_widget %}
308308
<div class="integer_widget">
309309
{% set type = type|default('number') %}
@@ -319,7 +319,7 @@ tell Symfony to use the template via the ``form_theme`` tag:
319319

320320
.. code-block:: html+twig
321321

322-
{% form_theme form 'AppBundle:Form:fields.html.twig' %}
322+
{% form_theme form 'form/fields.html.twig' %}
323323

324324
{{ form_widget(form.age) }}
325325

@@ -335,13 +335,12 @@ name of all the templates as an array using the ``with`` keyword:
335335

336336
.. code-block:: html+twig
337337

338-
{% form_theme form with ['::common.html.twig', ':Form:fields.html.twig',
339-
'AppBundle:Form:fields.html.twig'] %}
338+
{% form_theme form with ['common.html.twig', 'form/fields.html.twig'] %}
340339

341340
{# ... #}
342341

343-
The templates can be located at different bundles and they can even be stored
344-
at the global ``app/Resources/views/`` directory.
342+
The templates can also be located in different bundles, use the functional name
343+
to reference these templates, e.g. ``AcmeFormExtraBundle:form:fields.html.twig``.
345344

346345
Child Forms
347346
...........
@@ -350,16 +349,16 @@ You can also apply a form theme to a specific child of your form:
350349

351350
.. code-block:: html+twig
352351

353-
{% form_theme form.child 'AppBundle:Form:fields.html.twig' %}
352+
{% form_theme form.child 'form/fields.html.twig' %}
354353

355354
This is useful when you want to have a custom theme for a nested form that's
356355
different than the one of your main form. Just specify both your themes:
357356

358357
.. code-block:: html+twig
359358

360-
{% form_theme form 'AppBundle:Form:fields.html.twig' %}
359+
{% form_theme form 'form/fields.html.twig' %}
361360

362-
{% form_theme form.child 'AppBundle:Form:fields_child.html.twig' %}
361+
{% form_theme form.child 'form/fields_child.html.twig' %}
363362

364363
.. _cookbook-form-php-theming:
365364

@@ -375,9 +374,13 @@ file in order to customize the ``integer_widget`` fragment.
375374

376375
.. code-block:: html+php
377376

378-
<!-- app/Resources/views/Form/integer_widget.html.php -->
377+
<!-- app/Resources/views/form/integer_widget.html.php -->
379378
<div class="integer_widget">
380-
<?php echo $view['form']->block($form, 'form_widget_simple', array('type' => isset($type) ? $type : "number")) ?>
379+
<?php echo $view['form']->block(
380+
$form,
381+
'form_widget_simple',
382+
array('type' => isset($type) ? $type : "number")
383+
) ?>
381384
</div>
382385

383386
Now that you've created the customized form template, you need to tell Symfony
@@ -388,7 +391,7 @@ tell Symfony to use the theme via the ``setTheme`` helper method:
388391

389392
.. code-block:: php
390393
391-
<?php $view['form']->setTheme($form, array('AppBundle:Form')); ?>
394+
<?php $view['form']->setTheme($form, array(':form')); ?>
392395
393396
<?php $view['form']->widget($form['age']) ?>
394397
@@ -401,7 +404,14 @@ method:
401404

402405
.. code-block:: php
403406
404-
<?php $view['form']->setTheme($form['child'], 'AppBundle:Form/Child'); ?>
407+
<?php $view['form']->setTheme($form['child'], ':form'); ?>
408+
409+
.. note::
410+
411+
The ``:form`` syntax is based on the functional names for templates:
412+
``Bundle:Directory``. As the form directory lives in the
413+
``app/Resources/views`` directory, the ``Bundle`` part is empty, resulting
414+
in ``:form``.
405415

406416
.. _cookbook-form-twig-import-base-blocks:
407417

@@ -475,8 +485,8 @@ Twig
475485
~~~~
476486

477487
By using the following configuration, any customized form blocks inside the
478-
``AppBundle:Form:fields.html.twig`` template will be used globally when a
479-
form is rendered.
488+
``form/fields.html.twig`` template will be used globally when a form is
489+
rendered.
480490

481491
.. configuration-block::
482492

@@ -485,14 +495,14 @@ form is rendered.
485495
# app/config/config.yml
486496
twig:
487497
form_themes:
488-
- 'AppBundle:Form:fields.html.twig'
498+
- 'form/fields.html.twig'
489499
# ...
490500

491501
.. code-block:: xml
492502
493503
<!-- app/config/config.xml -->
494504
<twig:config>
495-
<twig:form-theme>AppBundle:Form:fields.html.twig</twig:form-theme>
505+
<twig:form-theme>form/fields.html.twig</twig:form-theme>
496506
<!-- ... -->
497507
</twig:config>
498508
@@ -501,7 +511,7 @@ form is rendered.
501511
// app/config/config.php
502512
$container->loadFromExtension('twig', array(
503513
'form_themes' => array(
504-
'AppBundle:Form:fields.html.twig',
514+
'form/fields.html.twig',
505515
),
506516

507517
// ...
@@ -677,7 +687,7 @@ customize the ``name`` field only:
677687
.. code-block:: html+php
678688

679689
<!-- Main template -->
680-
<?php echo $view['form']->setTheme($form, array('AppBundle:Form')); ?>
690+
<?php echo $view['form']->setTheme($form, array(':form')); ?>
681691

682692
<?php echo $view['form']->widget($form['name']); ?>
683693

@@ -735,7 +745,7 @@ You can also override the markup for an entire field row using the same method:
735745
.. code-block:: html+php
736746

737747
<!-- Main template -->
738-
<?php echo $view['form']->setTheme($form, array('AppBundle:Form')); ?>
748+
<?php echo $view['form']->setTheme($form, array(':form')); ?>
739749

740750
<?php echo $view['form']->row($form['name']); ?>
741751

cookbook/security/entity_provider.rst

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -422,20 +422,18 @@ both are unique in the database. Unfortunately, the native entity provider
422422
is only able to handle querying via a single property on the user.
423423

424424
To do this, make your ``UserRepository`` implement a special
425-
:class:`Symfony\\Component\\Security\\Core\\User\\UserProviderInterface`. This
426-
interface requires three methods: ``loadUserByUsername($username)``,
427-
``refreshUser(UserInterface $user)``, and ``supportsClass($class)``::
425+
:class:`Symfony\\Bridge\\Doctrine\\Security\\User\\UserLoaderInterface`. This
426+
interface only requires one method: ``loadUserByUsername($username)``::
428427

429428
// src/AppBundle/Entity/UserRepository.php
430429
namespace AppBundle\Entity;
431430

431+
use Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface;
432432
use Symfony\Component\Security\Core\User\UserInterface;
433-
use Symfony\Component\Security\Core\User\UserProviderInterface;
434433
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
435-
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
436434
use Doctrine\ORM\EntityRepository;
437435

438-
class UserRepository extends EntityRepository implements UserProviderInterface
436+
class UserRepository extends EntityRepository implements UserLoaderInterface
439437
{
440438
public function loadUserByUsername($username)
441439
{
@@ -456,30 +454,12 @@ interface requires three methods: ``loadUserByUsername($username)``,
456454

457455
return $user;
458456
}
459-
460-
public function refreshUser(UserInterface $user)
461-
{
462-
$class = get_class($user);
463-
if (!$this->supportsClass($class)) {
464-
throw new UnsupportedUserException(
465-
sprintf(
466-
'Instances of "%s" are not supported.',
467-
$class
468-
)
469-
);
470-
}
471-
472-
return $this->find($user->getId());
473-
}
474-
475-
public function supportsClass($class)
476-
{
477-
return $this->getEntityName() === $class
478-
|| is_subclass_of($class, $this->getEntityName());
479-
}
480457
}
481458

482-
For more details on these methods, see :class:`Symfony\\Component\\Security\\Core\\User\\UserProviderInterface`.
459+
.. versionadded:: 2.8
460+
The :class:`Symfony\\Bridge\\Doctrine\\Security\\User\\UserLoaderInterface`
461+
was introduced in 2.8. Prior to Symfony 2.8, you had to implement
462+
``Symfony\Component\Security\Core\User\UserProviderInterface``.
483463

484464
.. tip::
485465

create_framework/dependency-injection.rst renamed to create_framework/dependency_injection.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ empty class, you might be tempted to move some code from the front controller
77
to it::
88

99
// example.com/src/Simplex/Framework.php
10-
1110
namespace Simplex;
1211

1312
use Symfony\Component\Routing;
@@ -33,7 +32,6 @@ to it::
3332
The front controller code would become more concise::
3433

3534
// example.com/web/front.php
36-
3735
require_once __DIR__.'/../vendor/autoload.php';
3836

3937
use Symfony\Component\HttpFoundation\Request;
@@ -94,7 +92,6 @@ container:
9492
Create a new file to host the dependency injection container configuration::
9593

9694
// example.com/src/container.php
97-
9895
use Symfony\Component\DependencyInjection;
9996
use Symfony\Component\DependencyInjection\Reference;
10097

@@ -147,7 +144,6 @@ it in other object definitions.
147144
The front controller is now only about wiring everything together::
148145

149146
// example.com/web/front.php
150-
151147
require_once __DIR__.'/../vendor/autoload.php';
152148

153149
use Symfony\Component\HttpFoundation\Request;
@@ -165,7 +161,6 @@ As all the objects are now created in the dependency injection container, the
165161
framework code should be the previous simple version::
166162

167163
// example.com/src/Simplex/Framework.php
168-
169164
namespace Simplex;
170165

171166
use Symfony\Component\HttpKernel\HttpKernel;

0 commit comments

Comments
 (0)