Skip to content

Commit 6daf19f

Browse files
committed
Merge branch '2.6' into 2.7
* 2.6: Reordered the configuration blocks of the first example Fixed some errors and made some simplifications Added the "payload" option back (was removed by mistake) Fixed the order of the examples Simplified the first example and added more examples [Validator] Updated documentation of URL validator Fixed typos Removed duplication and moved a caution message [Console] Added a cookbook entry on invoking other commands [#5367] Making the titles more searchable fix #5487 Changed Authorization and Authentication to use subsections Split Security into Authentication & Authorization
2 parents 979c268 + 92e20cf commit 6daf19f

File tree

6 files changed

+193
-27
lines changed

6 files changed

+193
-27
lines changed

components/console/introduction.rst

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,8 @@ method::
477477
You can also test a whole console application by using
478478
:class:`Symfony\\Component\\Console\\Tester\\ApplicationTester`.
479479

480+
.. _calling-existing-command:
481+
480482
Calling an Existing Command
481483
---------------------------
482484

@@ -506,16 +508,27 @@ Calling a command from another one is straightforward::
506508
}
507509

508510
First, you :method:`Symfony\\Component\\Console\\Application::find` the
509-
command you want to execute by passing the command name.
510-
511-
Then, you need to create a new
512-
:class:`Symfony\\Component\\Console\\Input\\ArrayInput` with the arguments and
513-
options you want to pass to the command.
511+
command you want to execute by passing the command name. Then, you need to create
512+
a new :class:`Symfony\\Component\\Console\\Input\\ArrayInput` with the arguments
513+
and options you want to pass to the command.
514514

515515
Eventually, calling the ``run()`` method actually executes the command and
516516
returns the returned code from the command (return value from command's
517517
``execute()`` method).
518518

519+
.. tip::
520+
521+
If you want to suppress the output of the executed command, pass a
522+
:class:`Symfony\\Component\\Console\\Output\\NullOutput` as the second
523+
argument to ``$command->execute()``.
524+
525+
.. caution::
526+
527+
Note that all the commands will run in the same process and some of Symfony's
528+
built-in commands may not work well this way. For instance, the ``cache:clear``
529+
and ``cache:warmup`` commands change some class definitions, so running
530+
something after them is likely to break.
531+
519532
.. note::
520533

521534
Most of the time, calling a command from code that is not executed on the

cookbook/console/console_command.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@ before translating contents::
159159
However for other services the solution might be more complex. For more details,
160160
see :doc:`/cookbook/service_container/scopes`.
161161

162+
Invoking other Commands
163+
-----------------------
164+
165+
See :ref:`calling-existing-command` if you need to implement a command that runs
166+
other dependent commands.
167+
162168
Testing Commands
163169
----------------
164170

cookbook/map.rst.inc

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -155,21 +155,13 @@
155155
* :doc:`/cookbook/routing/redirect_trailing_slash`
156156
* :doc:`/cookbook/routing/extra_information`
157157

158-
* :doc:`/cookbook/security/index`
158+
* :doc:`Security Authentication (Identifying/Logging in the User) </cookbook/security/index>`
159159

160160
* :doc:`/cookbook/security/form_login_setup`
161161
* :doc:`/cookbook/security/entity_provider`
162162
* :doc:`/cookbook/security/remember_me`
163163
* :doc:`/cookbook/security/impersonating_user`
164-
* :doc:`/cookbook/security/voters`
165-
* :doc:`/cookbook/security/voters_data_permission`
166-
* :doc:`/cookbook/security/acl`
167-
* :doc:`/cookbook/security/acl_advanced`
168-
* :doc:`/cookbook/security/force_https`
169-
* :doc:`/cookbook/security/firewall_restriction`
170-
* :doc:`/cookbook/security/host_restriction`
171164
* :doc:`/cookbook/security/form_login`
172-
* :doc:`/cookbook/security/securing_services`
173165
* :doc:`/cookbook/security/custom_provider`
174166
* :doc:`/cookbook/security/custom_password_authenticator`
175167
* :doc:`/cookbook/security/api_key_authentication`
@@ -178,8 +170,19 @@
178170
* :doc:`/cookbook/security/target_path`
179171
* :doc:`/cookbook/security/csrf_in_login_form`
180172
* :doc:`/cookbook/security/named_encoders`
181-
* :doc:`/cookbook/security/access_control`
182173
* :doc:`/cookbook/security/multiple_user_providers`
174+
* :doc:`/cookbook/security/firewall_restriction`
175+
* :doc:`/cookbook/security/host_restriction`
176+
177+
* :doc:`Security Authorization (Denying Access) </cookbook/security/index>`
178+
179+
* :doc:`/cookbook/security/voters`
180+
* :doc:`/cookbook/security/voters_data_permission`
181+
* :doc:`/cookbook/security/acl`
182+
* :doc:`/cookbook/security/acl_advanced`
183+
* :doc:`/cookbook/security/force_https`
184+
* :doc:`/cookbook/security/securing_services`
185+
* :doc:`/cookbook/security/access_control`
183186

184187
* **Serializer**
185188

cookbook/security/index.rst

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
Security
22
========
33

4+
Authentication (Identifying/Logging in the User)
5+
------------------------------------------------
6+
47
.. toctree::
58
:maxdepth: 2
69

710
form_login_setup
811
entity_provider
912
remember_me
1013
impersonating_user
11-
voters
12-
voters_data_permission
13-
acl
14-
acl_advanced
15-
force_https
16-
firewall_restriction
17-
host_restriction
1814
form_login
19-
securing_services
2015
custom_provider
2116
custom_password_authenticator
2217
api_key_authentication
@@ -25,5 +20,20 @@ Security
2520
target_path
2621
csrf_in_login_form
2722
named_encoders
28-
access_control
2923
multiple_user_providers
24+
firewall_restriction
25+
host_restriction
26+
27+
Authorization (Denying Access)
28+
------------------------------
29+
30+
.. toctree::
31+
:maxdepth: 2
32+
33+
voters
34+
voters_data_permission
35+
acl
36+
acl_advanced
37+
force_https
38+
securing_services
39+
access_control

create_framework/unit-testing.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ We are now ready to write our first test::
9696
->method('match')
9797
->will($this->throwException($exception))
9898
;
99+
$matcher
100+
->expects($this->once())
101+
->method('getContext')
102+
->will($this->returnValue($this->getMock('Symfony\Component\Routing\RequestContext')))
103+
;
99104
$resolver = $this->getMock('Symfony\Component\HttpKernel\Controller\ControllerResolverInterface');
100105

101106
return new Framework($matcher, $resolver);

reference/constraints/Url.rst

Lines changed: 132 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,142 @@ message
8484

8585
This message is shown if the URL is invalid.
8686

87+
.. configuration-block::
88+
89+
.. code-block:: php-annotations
90+
91+
// src/Acme/BlogBundle/Entity/Author.php
92+
namespace Acme\BlogBundle\Entity;
93+
94+
use Symfony\Component\Validator\Constraints as Assert;
95+
96+
class Author
97+
{
98+
/**
99+
* @Assert\Url(
100+
* message = "The url '{{ value }}' is not a valid url",
101+
* )
102+
*/
103+
protected $bioUrl;
104+
}
105+
106+
.. code-block:: yaml
107+
108+
# src/Acme/BlogBundle/Resources/config/validation.yml
109+
Acme\BlogBundle\Entity\Author:
110+
properties:
111+
bioUrl:
112+
- Url:
113+
message: The url "{{ value }}" is not a valid url.
114+
115+
.. code-block:: xml
116+
117+
<!-- src/Acme/BlogBundle/Resources/config/validation.xml -->
118+
<?xml version="1.0" encoding="UTF-8" ?>
119+
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
120+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
121+
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
122+
123+
<class name="Acme\BlogBundle\Entity\Author">
124+
<property name="bioUrl">
125+
<constraint name="Url">
126+
<option name="message">The url "{{ value }}" is not a valid url.</option>
127+
</constraint>
128+
</property>
129+
</class>
130+
</constraint-mapping>
131+
132+
.. code-block:: php
133+
134+
// src/Acme/BlogBundle/Entity/Author.php
135+
namespace Acme\BlogBundle\Entity;
136+
137+
use Symfony\Component\Validator\Mapping\ClassMetadata;
138+
use Symfony\Component\Validator\Constraints as Assert;
139+
140+
class Author
141+
{
142+
public static function loadValidatorMetadata(ClassMetadata $metadata)
143+
{
144+
$metadata->addPropertyConstraint('bioUrl', new Assert\Url(array(
145+
'message' => 'The url "{{ value }}" is not a valid url.',
146+
)));
147+
}
148+
}
149+
87150
protocols
88151
~~~~~~~~~
89152

90153
**type**: ``array`` **default**: ``array('http', 'https')``
91154

92-
The protocols that will be considered to be valid. For example, if you also
93-
needed ``ftp://`` type URLs to be valid, you'd redefine the ``protocols``
94-
array, listing ``http``, ``https`` and also ``ftp``.
155+
The protocols considered to be valid for the URL. For example, if you also consider
156+
the ``ftp://`` type URLs to be valid, redefine the ``protocols`` array, listing
157+
``http``, ``https``, and also ``ftp``.
158+
159+
.. configuration-block::
160+
161+
.. code-block:: php-annotations
162+
163+
// src/Acme/BlogBundle/Entity/Author.php
164+
namespace Acme\BlogBundle\Entity;
165+
166+
use Symfony\Component\Validator\Constraints as Assert;
167+
168+
class Author
169+
{
170+
/**
171+
* @Assert\Url(
172+
* protocols = {"http", "https", "ftp"}
173+
* )
174+
*/
175+
protected $bioUrl;
176+
}
177+
178+
.. code-block:: yaml
179+
180+
# src/Acme/BlogBundle/Resources/config/validation.yml
181+
Acme\BlogBundle\Entity\Author:
182+
properties:
183+
bioUrl:
184+
- Url: { protocols: [http, https, ftp] }
185+
186+
.. code-block:: xml
187+
188+
<!-- src/Acme/BlogBundle/Resources/config/validation.xml -->
189+
<?xml version="1.0" encoding="UTF-8" ?>
190+
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
191+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
192+
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
193+
194+
<class name="Acme\BlogBundle\Entity\Author">
195+
<property name="bioUrl">
196+
<constraint name="Url">
197+
<option name="protocols">
198+
<value>http</value>
199+
<value>https</value>
200+
<value>ftp</value>
201+
</option>
202+
</constraint>
203+
</property>
204+
</class>
205+
</constraint-mapping>
206+
207+
.. code-block:: php
208+
209+
// src/Acme/BlogBundle/Entity/Author.php
210+
namespace Acme\BlogBundle\Entity;
211+
212+
use Symfony\Component\Validator\Mapping\ClassMetadata;
213+
use Symfony\Component\Validator\Constraints as Assert;
214+
215+
class Author
216+
{
217+
public static function loadValidatorMetadata(ClassMetadata $metadata)
218+
{
219+
$metadata->addPropertyConstraint('bioUrl', new Assert\Url(array(
220+
'protocols' => array('http', 'https', 'ftp'),
221+
)));
222+
}
223+
}
95224
96225
.. include:: /reference/constraints/_payload-option.rst.inc

0 commit comments

Comments
 (0)