Skip to content

Commit a95f4f0

Browse files
committed
Merge branch '3.4'
* 3.4: (27 commits) setfacl commands in the right order add missing options allowed with an env variable [#7941] use class constant Update guard_authentication.rst Fix typo in a class name Fix typo Fixed trivial code example typo Fix typo Fix method reference (`getSubscribedServices()` instead of `getSubscribedEvents()`) Fixed code indentation use Ldap instead of the deprecated LdapClient Fix choice keys and values for custom field types [#7946] fix PHP parameter config example Tiny clarification to Finder component docs [#7917] add LDAP extension link Updated code example for LDAP integration Syntax to create an email Update usage.rst Correct default firewall name on Security docs Fix small typo ...
2 parents faf37e9 + c3f8980 commit a95f4f0

25 files changed

+199
-161
lines changed

components/config/definition.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,14 @@ values::
141141

142142
$rootNode
143143
->children()
144-
->enumNode('gender')
145-
->values(array('male', 'female'))
144+
->enumNode('delivery')
145+
->values(array('standard', 'expedited', 'priority'))
146146
->end()
147147
->end()
148148
;
149149

150-
This will restrict the ``gender`` option to be either ``male`` or ``female``.
150+
This will restrict the ``delivery`` options to be either ``standard``,
151+
``expedited`` or ``priority``.
151152

152153
Array Nodes
153154
~~~~~~~~~~~

components/dependency_injection/compilation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ makes dumping the compiled container easy::
472472
}
473473

474474
``ProjectServiceContainer`` is the default name given to the dumped container
475-
class, you can change this though this with the ``class`` option when you
475+
class. However you can change this with the ``class`` option when you
476476
dump it::
477477

478478
// ...

components/finder.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ the Finder instance.
5050

5151
.. tip::
5252

53-
A Finder instance is a PHP :phpclass:`Iterator`. So, instead of iterating over the
53+
A Finder instance is a PHP :phpclass:`Iterator`. So, in addition to iterating over the
5454
Finder with ``foreach``, you can also convert it to an array with the
5555
:phpfunction:`iterator_to_array` method, or get the number of items with
5656
:phpfunction:`iterator_count`.

components/ldap.rst

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ You can install the component in 2 different ways:
2020
Usage
2121
-----
2222

23-
The :class:`Symfony\\Component\\Ldap\\LdapClient` class provides methods
24-
to authenticate and query against an LDAP server.
23+
The :class:`Symfony\\Component\\Ldap\\Ldap` class provides methods to authenticate
24+
and query against an LDAP server.
2525

26-
The :class:`Symfony\\Component\\Ldap\\LdapClient` class can be configured
26+
The ``Ldap`` class uses an :class:`Symfony\\Component\\Ldap\\Adapter\\AdapterInterface`
27+
to communicate with an LDAP server. The :class:`adapter <Symfony\\Component\\Ldap\\Adapter\\ExtLdap\\Adapter>`
28+
for PHP's built-in LDAP extension, for example, can be configured
2729
using the following options:
2830

2931
``host``
@@ -47,24 +49,32 @@ using the following options:
4749

4850
For example, to connect to a start-TLS secured LDAP server::
4951

50-
use Symfony\Component\Ldap\LdapClient;
51-
52-
$ldap = new LdapClient('my-server', 389, 3, false, true);
53-
54-
The :method:`Symfony\\Component\\Ldap\\LdapClient::bind` method
52+
use Symfony\Component\Ldap\Adapter\ExtLdap\Adapter;
53+
use Symfony\Component\Ldap\Ldap;
54+
55+
$adapter = new Adapter(array(
56+
'host' => 'my-server',
57+
'port' => 389,
58+
'encryption' => 'tls',
59+
'options' => array(
60+
'protocol_version' => 3,
61+
'referrals' => false,
62+
),
63+
));
64+
$ldap = new Ldap($adapter);
65+
66+
The :method:`Symfony\\Component\\Ldap\\Ldap::bind` method
5567
authenticates a previously configured connection using both the
5668
distinguished name (DN) and the password of a user::
5769

58-
use Symfony\Component\Ldap\LdapClient;
5970
// ...
6071

6172
$ldap->bind($dn, $password);
6273

6374
Once bound (or if you enabled anonymous authentication on your
6475
LDAP server), you may query the LDAP server using the
65-
:method:`Symfony\\Component\\Ldap\\LdapClient::find` method::
76+
:method:`Symfony\\Component\\Ldap\\Ldap::find` method::
6677

67-
use Symfony\Component\Ldap\LdapClient;
6878
// ...
6979

7080
$ldap->find('dc=symfony,dc=com', '(&(objectclass=person)(ou=Maintainers))');

components/security/authentication.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,6 @@ The ``security.interactive_login`` event is triggered after a user has actively
305305
logged into your website. It is important to distinguish this action from
306306
non-interactive authentication methods, such as:
307307

308-
* authentication based on a "remember me" cookie.
309308
* authentication based on your session.
310309
* authentication using a HTTP basic or HTTP digest header.
311310

controller/service.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ The best way to see how to replace base ``Controller`` convenience methods is to
130130
look at the `ControllerTrait`_ that holds its logic.
131131

132132
If you want to know what type-hints to use for each service, see the
133-
``getSubscribedEvents()`` method in `AbstractController`_.
133+
``getSubscribedServices()`` method in `AbstractController`_.
134134

135135
.. _`Controller class source code`: https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php
136136
.. _`base Controller class`: https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php

controller/soap_web_service.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ In this case, the SOAP service will allow the client to call a method called
3939
public function hello($name)
4040
{
4141

42-
$message = \Swift_Message::newInstance()
42+
$message = new \Swift_Message('Hello Service')
4343
->setTo('me@example.com')
44-
->setSubject('Hello Service')
4544
->setBody($name . ' says hi!');
4645

4746
$this->mailer->send($message);

doctrine.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -633,9 +633,9 @@ Fetching an object back out of the database is even easier. For example,
633633
suppose you've configured a route to display a specific ``Product`` based
634634
on its ``id`` value::
635635

636-
use Doctrine\ORM\EnityManagerInterface;
636+
use Doctrine\ORM\EntityManagerInterface;
637637

638-
public function showAction($productId, EnityManagerInterface $em)
638+
public function showAction($productId, EntityManagerInterface $em)
639639
{
640640
$product = $em->getRepository('AppBundle:Product')
641641
->find($productId);
@@ -727,7 +727,7 @@ Updating an Object
727727
Once you've fetched an object from Doctrine, updating it is easy. Suppose
728728
you have a route that maps a product id to an update action in a controller::
729729

730-
use Doctrine\ORM\EnityManagerInterface;
730+
use Doctrine\ORM\EntityManagerInterface;
731731

732732
public function updateAction($productId, EntityManagerInterface $em)
733733
{

email.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ an email is pretty straightforward::
103103

104104
public function indexAction($name, \Swift_Mailer $mailer)
105105
{
106-
$message = \Swift_Message::newInstance()
107-
->setSubject('Hello Email')
106+
$message = new \Swift_Message('Hello Email')
108107
->setFrom('send@example.com')
109108
->setTo('recipient@example.com')
110109
->setBody(

email/dev_environment.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ Now, suppose you're sending an email to ``recipient@example.com``.
100100
101101
public function indexAction($name, \Swift_Mailer $mailer)
102102
{
103-
$message = \Swift_Message::newInstance()
104-
->setSubject('Hello Email')
103+
$message = new \Swift_Message('Hello Email')
105104
->setFrom('send@example.com')
106105
->setTo('recipient@example.com')
107106
->setBody(

email/testing.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ Start with an easy controller action that sends an email::
1414

1515
public function sendEmailAction($name, \Swift_Mailer $mailer)
1616
{
17-
$message = \Swift_Message::newInstance()
18-
->setSubject('Hello Email')
17+
$message = new \Swift_Message('Hello Email')
1918
->setFrom('send@example.com')
2019
->setTo('recipient@example.com')
2120
->setBody('You should see me from the profiler!')

form/create_custom_field_type.rst

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ How to Create a Custom Form Field Type
77
Symfony comes with a bunch of core field types available for building forms.
88
However there are situations where you may want to create a custom form field
99
type for a specific purpose. This recipe assumes you need a field definition
10-
that holds a person's gender, based on the existing choice field. This section
10+
that holds a shipping option, based on the existing choice field. This section
1111
explains how the field is defined, how you can customize its layout and finally,
1212
how you can register it for use in your application.
1313

@@ -16,25 +16,26 @@ Defining the Field Type
1616

1717
In order to create the custom field type, first you have to create the class
1818
representing the field. In this situation the class holding the field type
19-
will be called ``GenderType`` and the file will be stored in the default location
19+
will be called ``ShippingType`` and the file will be stored in the default location
2020
for form fields, which is ``<BundleName>\Form\Type``. Make sure the field extends
2121
:class:`Symfony\\Component\\Form\\AbstractType`::
2222

23-
// src/AppBundle/Form/Type/GenderType.php
23+
// src/AppBundle/Form/Type/ShippingType.php
2424
namespace AppBundle\Form\Type;
2525

2626
use Symfony\Component\Form\AbstractType;
2727
use Symfony\Component\OptionsResolver\OptionsResolver;
2828
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
2929

30-
class GenderType extends AbstractType
30+
class ShippingType extends AbstractType
3131
{
3232
public function configureOptions(OptionsResolver $resolver)
3333
{
3434
$resolver->setDefaults(array(
3535
'choices' => array(
36-
'm' => 'Male',
37-
'f' => 'Female',
36+
'Standard Shipping' => 'standard',
37+
'Expedited Shipping' => 'expedited',
38+
'Priority Shipping' => 'priority',
3839
)
3940
));
4041
}
@@ -67,8 +68,8 @@ important:
6768
This method is used to set any extra variables you'll
6869
need when rendering your field in a template. For example, in `ChoiceType`_,
6970
a ``multiple`` variable is set and used in the template to set (or not
70-
set) the ``multiple`` attribute on the ``select`` field. See `Creating a Template for the Field`_
71-
for more details.
71+
set) the ``multiple`` attribute on the ``select`` field. See
72+
`Creating a Template for the Field`_ for more details.
7273

7374
``configureOptions()``
7475
This defines options for your form type that
@@ -83,9 +84,9 @@ important:
8384
Also, if you need to modify the "view" of any of your child types from
8485
your parent type, use the ``finishView()`` method.
8586

86-
The goal of this field was to extend the choice type to enable selection of
87-
a gender. This is achieved by fixing the ``choices`` to a list of possible
88-
genders.
87+
The goal of this field was to extend the choice type to enable selection of the
88+
shipping type. This is achieved by fixing the ``choices`` to a list of available
89+
shipping options.
8990

9091
Creating a Template for the Field
9192
---------------------------------
@@ -95,9 +96,9 @@ the class name of your type. For more information, see :ref:`form-customization-
9596

9697
.. note::
9798

98-
The first part of the prefix (e.g. ``gender``) comes from the class name
99-
(``GenderType`` -> ``gender``). This can be controlled by overriding ``getBlockPrefix()``
100-
in ``GenderType``.
99+
The first part of the prefix (e.g. ``shipping``) comes from the class name
100+
(``ShippingType`` -> ``shipping``). This can be controlled by overriding ``getBlockPrefix()``
101+
in ``ShippingType``.
101102

102103
.. caution::
103104

@@ -113,14 +114,14 @@ any work as the custom field type will automatically be rendered like a ``Choice
113114
But for the sake of this example, suppose that when your field is "expanded"
114115
(i.e. radio buttons or checkboxes, instead of a select field), you want to
115116
always render it in a ``ul`` element. In your form theme template (see above
116-
link for details), create a ``gender_widget`` block to handle this:
117+
link for details), create a ``shipping_widget`` block to handle this:
117118

118119
.. configuration-block::
119120

120121
.. code-block:: html+twig
121122

122123
{# app/Resources/views/form/fields.html.twig #}
123-
{% block gender_widget %}
124+
{% block shipping_widget %}
124125
{% spaceless %}
125126
{% if expanded %}
126127
<ul {{ block('widget_container_attributes') }}>
@@ -140,7 +141,7 @@ link for details), create a ``gender_widget`` block to handle this:
140141

141142
.. code-block:: html+php
142143

143-
<!-- app/Resources/views/form/gender_widget.html.php -->
144+
<!-- app/Resources/views/form/shipping_widget.html.php -->
144145
<?php if ($expanded) : ?>
145146
<ul <?php $view['form']->block($form, 'widget_container_attributes') ?>>
146147
<?php foreach ($form as $child) : ?>
@@ -158,7 +159,7 @@ link for details), create a ``gender_widget`` block to handle this:
158159
.. note::
159160

160161
Make sure the correct widget prefix is used. In this example the name should
161-
be ``gender_widget`` (see :ref:`form-customization-form-themes`).
162+
be ``shipping_widget`` (see :ref:`form-customization-form-themes`).
162163
Further, the main config file should point to the custom form template
163164
so that it's used when rendering all forms.
164165

@@ -255,20 +256,20 @@ new instance of the type in one of your forms::
255256

256257
use Symfony\Component\Form\AbstractType;
257258
use Symfony\Component\Form\FormBuilderInterface;
258-
use AppBundle\Form\Type\GenderType;
259+
use AppBundle\Form\Type\ShippingType;
259260

260-
class AuthorType extends AbstractType
261+
class OrderType extends AbstractType
261262
{
262263
public function buildForm(FormBuilderInterface $builder, array $options)
263264
{
264-
$builder->add('gender_code', GenderType::class, array(
265-
'placeholder' => 'Choose a gender',
265+
$builder->add('shipping_code', ShippingType::class, array(
266+
'placeholder' => 'Choose a delivery option',
266267
));
267268
}
268269
}
269270

270-
But this only works because the ``GenderType`` is very simple. What if
271-
the gender codes were stored in configuration or in a database? The next
271+
But this only works because the ``ShippingType()`` is very simple. What if
272+
the shipping codes were stored in configuration or in a database? The next
272273
section explains how more complex field types solve this problem.
273274

274275
.. _form-field-service:
@@ -280,13 +281,13 @@ Accessing Services and Config
280281
If you need to access :doc:`services </service_container>` from your form class,
281282
add a ``__construct()`` method like normal::
282283

283-
// src/AppBundle/Form/Type/GenderType.php
284+
// src/AppBundle/Form/Type/ShippingType.php
284285
namespace AppBundle\Form\Type;
285286

286287
// ...
287288
use Doctrine\ORM\EntityManagerInterface;
288289

289-
class GenderType extends AbstractType
290+
class ShippingType extends AbstractType
290291
{
291292
private $em;
292293

form/unit_testing.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ allows you to return a list of extensions to register::
174174
// ...
175175
use AppBundle\Form\Type\TestedType;
176176
use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
177+
use Symfony\Component\Form\Form;
177178
use Symfony\Component\Validator\ConstraintViolationList;
179+
use Symfony\Component\Validator\Mapping\ClassMetadata;
178180
use Symfony\Component\Validator\Validator\ValidatorInterface;
179181

180182
class TestedTypeTest extends TypeTestCase
@@ -189,6 +191,9 @@ allows you to return a list of extensions to register::
189191
$this->validator
190192
->method('validate')
191193
->will($this->returnValue(new ConstraintViolationList()));
194+
$validator
195+
->method('getMetadataFor')
196+
->will($this->returnValue(new ClassMetadata(Form::class)));
192197

193198
return array(
194199
new ValidatorExtension($this->validator),

reference/configuration/swiftmailer.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@ the information will be available in the profiler.
232232

233233
The following options can be set via environment variables using the
234234
``%env()%`` syntax: ``url``, ``transport``, ``username``, ``password``,
235-
``host``, ``port``, ``timeout``, ``source_ip``, ``local_domain``.
235+
``host``, ``port``, ``timeout``, ``source_ip``, ``local_domain``,
236+
``encryption``, ``auth_mode``.
236237
For details, see the :doc:`/configuration/external_parameters` article.
237238

238239
Full Default Configuration

0 commit comments

Comments
 (0)