Skip to content

Commit b1e0886

Browse files
committed
Merge branch '2.4'
2 parents 33d27cc + 780cd22 commit b1e0886

18 files changed

+158
-54
lines changed

book/forms.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,8 @@ that will house the logic for building the task form::
10061006
{
10071007
public function buildForm(FormBuilderInterface $builder, array $options)
10081008
{
1009-
$builder->add('task')
1009+
$builder
1010+
->add('task')
10101011
->add('dueDate', null, array('widget' => 'single_text'))
10111012
->add('save', 'submit');
10121013
}

book/page_creation.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ an entry when you generated the ``AcmeHelloBundle``:
165165
$collection = new RouteCollection();
166166
$collection->addCollection(
167167
$loader->import('@AcmeHelloBundle/Resources/config/routing.php'),
168-
'/',
168+
'/'
169169
);
170170
171171
return $collection;

book/routing.rst

+10-8
Original file line numberDiff line numberDiff line change
@@ -558,13 +558,15 @@ is *not* a number).
558558
As a result, a URL like ``/blog/my-blog-post`` will now properly match the
559559
``blog_show`` route.
560560

561-
+--------------------+-----------+-----------------------+
562-
| URL | route | parameters |
563-
+====================+===========+=======================+
564-
| /blog/2 | blog | {page} = 2 |
565-
+--------------------+-----------+-----------------------+
566-
| /blog/my-blog-post | blog_show | {slug} = my-blog-post |
567-
+--------------------+-----------+-----------------------+
561+
+----------------------+-----------+-------------------------+
562+
| URL | route | parameters |
563+
+======================+===========+=========================+
564+
| /blog/2 | blog | {page} = 2 |
565+
+----------------------+-----------+-------------------------+
566+
| /blog/my-blog-post | blog_show | {slug} = my-blog-post |
567+
+----------------------+-----------+-------------------------+
568+
| /blog/2-my-blog-post | blog_show | {slug} = 2-my-blog-post |
569+
+----------------------+-----------+-------------------------+
568570

569571
.. sidebar:: Earlier Routes always Win
570572

@@ -1131,7 +1133,7 @@ instead of simply ``/hello/{name}``:
11311133
$acmeHello = $loader->import(
11321134
"@AcmeHelloBundle/Resources/config/routing.php"
11331135
);
1134-
$acmeHello->setPrefix('/admin');
1136+
$acmeHello->addPrefix('/admin');
11351137
11361138
$collection->addCollection($acmeHello);
11371139

book/security.rst

+67-1
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,73 @@ the user will be redirected to ``https``:
10621062
),
10631063
),
10641064
1065+
.. _book-security-securing-controller:
1066+
1067+
Securing a Controller
1068+
~~~~~~~~~~~~~~~~~~~~~
1069+
1070+
Protecting your application based on URL patterns is easy, but may not be
1071+
fine-grained enough in certain cases. When necessary, you can easily force
1072+
authorization from inside a controller::
1073+
1074+
// ...
1075+
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
1076+
1077+
public function helloAction($name)
1078+
{
1079+
if (false === $this->get('security.context')->isGranted('ROLE_ADMIN')) {
1080+
throw new AccessDeniedException();
1081+
}
1082+
1083+
// ...
1084+
}
1085+
1086+
.. _book-security-securing-controller-annotations:
1087+
1088+
Thanks to the SensioFrameworkExtraBundle, you can also secure your controller using annotations::
1089+
1090+
// ...
1091+
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
1092+
1093+
/**
1094+
* @Security("has_role('ROLE_ADMIN')")
1095+
*/
1096+
public function helloAction($name)
1097+
{
1098+
// ...
1099+
}
1100+
1101+
For more information, see the
1102+
:doc:`FrameworkExtraBundle documentation </bundles/SensioFrameworkExtraBundle/annotations/security>`.
1103+
1104+
Securing other Services
1105+
~~~~~~~~~~~~~~~~~~~~~~~
1106+
1107+
In fact, anything in Symfony can be protected using a strategy similar to
1108+
the one seen in the previous section. For example, suppose you have a service
1109+
(i.e. a PHP class) whose job is to send emails from one user to another.
1110+
You can restrict use of this class - no matter where it's being used from -
1111+
to users that have a specific role.
1112+
1113+
For more information on how you can use the Security component to secure
1114+
different services and methods in your application, see :doc:`/cookbook/security/securing_services`.
1115+
1116+
Access Control Lists (ACLs): Securing Individual Database Objects
1117+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1118+
1119+
Imagine you are designing a blog system where your users can comment on your
1120+
posts. Now, you want a user to be able to edit their own comments, but not
1121+
those of other users. Also, as the admin user, you yourself want to be able
1122+
to edit *all* comments.
1123+
1124+
The Security component comes with an optional access control list (ACL) system
1125+
that you can use when you need to control access to individual instances
1126+
of an object in your system. *Without* ACL, you can secure your system so that
1127+
only certain users can edit blog comments in general. But *with* ACL, you
1128+
can restrict or allow access on a comment-by-comment basis.
1129+
1130+
For more information, see the cookbook article: :doc:`/cookbook/security/acl`.
1131+
10651132
Users
10661133
-----
10671134

@@ -2091,7 +2158,6 @@ Learn more from the Cookbook
20912158
* :doc:`Access Control Lists (ACLs) </cookbook/security/acl>`
20922159
* :doc:`/cookbook/security/remember_me`
20932160

2094-
.. _`JMSSecurityExtraBundle`: http://jmsyst.com/bundles/JMSSecurityExtraBundle/1.2
20952161
.. _`FOSUserBundle`: https://github.com./FriendsOfSymfony/FOSUserBundle
20962162
.. _`implement the \Serializable interface`: http://php.net/manual/en/class.serializable.php
20972163
.. _`functions-online.com`: http://www.functions-online.com/sha1.html

book/validation.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1148,7 +1148,7 @@ section .
11481148
The ``validateValue`` method returns a :class:`Symfony\\Component\\Validator\\ConstraintViolationList`
11491149
object, which acts just like an array of errors. Each error in the collection
11501150
is a :class:`Symfony\\Component\\Validator\\ConstraintViolation` object,
1151-
which holds the error message on its `getMessage` method.
1151+
which holds the error message on its ``getMessage`` method.
11521152

11531153
Final Thoughts
11541154
--------------

components/console/introduction.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ You can also set these colors and options inside the tagname::
160160
// bold text on a yellow background
161161
$output->writeln('<bg=yellow;options=bold>foo</bg=yellow;options=bold>');
162162

163-
.. verbosity-levels:
163+
.. _verbosity-levels:
164164

165165
Verbosity Levels
166166
~~~~~~~~~~~~~~~~

components/dependency_injection/factories.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ factory itself as a service:
125125
126126
$container->setDefinition('newsletter_factory', new Definition(
127127
'%newsletter_factory.class%'
128-
))
128+
));
129129
$container->setDefinition('newsletter_manager', new Definition(
130130
'%newsletter_manager.class%'
131131
))->setFactoryService(
@@ -193,7 +193,7 @@ in the previous example takes the ``templating`` service as an argument:
193193
194194
$container->setDefinition('newsletter_factory', new Definition(
195195
'%newsletter_factory.class%'
196-
))
196+
));
197197
$container->setDefinition('newsletter_manager', new Definition(
198198
'%newsletter_manager.class%',
199199
array(new Reference('templating'))

components/form/introduction.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ object to read data off of the correct PHP superglobals (i.e. ``$_POST`` or
8484
:class:`Symfony\\Component\\Form\\Extension\\HttpFoundation\\HttpFoundationExtension`
8585
to your form factory::
8686

87-
use Symfony\Component\Form\Forms;
88-
use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationExtension;
87+
use Symfony\Component\Form\Forms;
88+
use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationExtension;
8989

90-
$formFactory = Forms::createFormFactoryBuilder()
91-
->addExtension(new HttpFoundationExtension())
92-
->getFormFactory();
90+
$formFactory = Forms::createFormFactoryBuilder()
91+
->addExtension(new HttpFoundationExtension())
92+
->getFormFactory();
9393

9494
Now, when you process a form, you can pass the :class:`Symfony\\Component\\HttpFoundation\\Request`
9595
object to :method:`Symfony\\Component\\Form\\Form::handleRequest`::

components/process.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ and :method:`Symfony\\Component\\Process\\Process::getIncrementalErrorOutput`
4343
methods returns the new outputs since the last call.
4444

4545
.. versionadded:: 2.4
46-
The ``flushOutput()`` and ``flushErrorOutput()`` methods were added in Symfony 2.4.
46+
The ``clearOutput()`` and ``clearErrorOutput()`` methods were added in Symfony 2.4.
4747

48-
The :method:`Symfony\\Component\\Process\\Process::flushOutput` method flushes
48+
The :method:`Symfony\\Component\\Process\\Process::clearOutput` method clears
4949
the contents of the output and
50-
:method:`Symfony\\Component\\Process\\Process::flushErrorOutput` flushes
50+
:method:`Symfony\\Component\\Process\\Process::clearErrorOutput` clears
5151
the contents of the error output.
5252

5353
Getting real-time Process Output

cookbook/bundles/remove.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ starting a project, but you'll probably want to eventually remove it.
1717
---------------------------------------------
1818

1919
To disconnect the bundle from the framework, you should remove the bundle from
20-
the ``Appkernel::registerBundles()`` method. The bundle is normally found in
20+
the ``AppKernel::registerBundles()`` method. The bundle is normally found in
2121
the ``$bundles`` array but the AcmeDemoBundle is only registered in a
2222
development environment and you can find him in the if statement after::
2323

cookbook/console/logging.rst

+7-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ container and use it to do the logging::
3434
use Symfony\Component\Console\Input\InputInterface;
3535
use Symfony\Component\Console\Input\InputOption;
3636
use Symfony\Component\Console\Output\OutputInterface;
37-
use \Psr\Log\LoggerInterface;
37+
use Psr\Log\LoggerInterface;
3838

3939
class GreetCommand extends ContainerAwareCommand
4040
{
@@ -150,7 +150,8 @@ Then implement the actual listener::
150150
$this->logger = $logger;
151151
}
152152

153-
public function onConsoleException(ConsoleExceptionEvent $event) {
153+
public function onConsoleException(ConsoleExceptionEvent $event)
154+
{
154155
$command = $event->getCommand();
155156
$exception = $event->getException();
156157

@@ -170,7 +171,7 @@ Then implement the actual listener::
170171
In the code above, when any command throws an exception, the listener will
171172
receive an event. You can simply log it by passing the logger service via the
172173
service configuration. Your method receives a
173-
:class:`Symfony\\Component\\Console\\Event\\ConsoleExceptionEvent`` object,
174+
:class:`Symfony\\Component\\Console\\Event\\ConsoleExceptionEvent` object,
174175
which has methods to get information about the event and the exception.
175176

176177
Logging non-0 exit statuses
@@ -241,7 +242,7 @@ First configure a listener for console terminate events in the service container
241242
Then implement the actual listener::
242243

243244
// src/Acme/DemoBundle/EventListener/ConsoleExceptionListener.php
244-
namespace Acme/DemoBundle\EventListener;
245+
namespace Acme\DemoBundle\EventListener;
245246

246247
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
247248
use Psr\Log\LoggerInterface;
@@ -255,7 +256,8 @@ Then implement the actual listener::
255256
$this->logger = $logger;
256257
}
257258

258-
public function onConsoleTerminate(ConsoleTerminateEvent $event) {
259+
public function onConsoleTerminate(ConsoleTerminateEvent $event)
260+
{
259261
$statusCode = $event->getExitCode();
260262
$command = $event->getCommand();
261263

cookbook/form/dynamic_form_modification.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ Adding an Event Subscriber to a Form Class
163163

164164
For better reusability or if there is some heavy logic in your event listener,
165165
you can also move the logic for creating the ``name`` field to an
166-
:ref:`event subscriber <event_dispatcher-using-event-subscribers:ref:>`::
166+
:ref:`event subscriber <event_dispatcher-using-event-subscribers>`::
167167

168168
// src/Acme/DemoBundle/Form/Type/ProductType.php
169169
namespace Acme\DemoBundle\Form\Type;

cookbook/logging/monolog_console.rst

+11-10
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
How to Configure Monolog to Display Console Messages
55
====================================================
66

7-
.. versionadded:: 2.3
8-
This feature was introduced to the MonologBundle in version 2.4, which
9-
was first packaged with Symfony at version 2.4 (but compatible with Symfony 2.3).
7+
.. versionadded:: 2.4
8+
This feature was introduced to the MonologBridge in Symfony 2.4.
109

11-
It is possible to use the console to print messages for certain :ref:`verbosity-levels`
12-
using the :class:`Symfony\\Component\\Console\\Output\\OutputInterface`
13-
instance that is passed when a command gets executed.
10+
It is possible to use the console to print messages for certain
11+
:ref:`verbosity levels <verbosity-levels>` using the
12+
:class:`Symfony\\Component\\Console\\Output\\OutputInterface` instance that
13+
is passed when a command gets executed.
1414

1515
When a lot of logging has to happen, it's cumbersome to print information
1616
depending on the verbosity settings (``-v``, ``-vv``, ``-vvv``) because the
@@ -32,7 +32,7 @@ For example::
3232
}
3333

3434
Instead of using these semantic methods to test for each of the verbosity
35-
levels, `MonologBundle`_ 2.4 provides a `ConsoleHandler`_ that listens to
35+
levels, the `MonologBridge`_ provides a `ConsoleHandler`_ that listens to
3636
console events and writes log messages to the console output depending on the
3737
current log level and the console verbosity.
3838

@@ -96,8 +96,9 @@ With the ``verbosity_levels`` option you can adapt the mapping between
9696
verbosity and log level. In the given example it will also show notices in
9797
normal verbosity mode (instead of warnings only). Additionally, it will only
9898
use messages logged with the custom ``my_channel`` channel and it changes the
99-
display style via a custom formatter. See also the :doc:`reference/configuration/monolog`
100-
for more information:
99+
display style via a custom formatter (see the
100+
:doc:`MonologBundle reference </reference/configuration/monolog>` for more
101+
information):
101102

102103
.. configuration-block::
103104

@@ -180,4 +181,4 @@ for more information:
180181
;
181182
182183
.. _ConsoleHandler: https://github.com./symfony/MonologBridge/blob/master/Handler/ConsoleHandler.php
183-
.. _MonologBundle: https://github.com./symfony/MonologBundle
184+
.. _MonologBridge: https://github.com./symfony/MonologBridge

cookbook/session/sessions_directory.rst

+38-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
.. index::
22
single: Sessions, sessions directory
33

4-
Configuring the Directory where Sessions Files are Saved
4+
Configuring the Directory Where Sessions Files are Saved
55
========================================================
66

7-
By default, Symfony stores the session data in the cache directory. This
8-
means that when you clear the cache, any current sessions will also be
9-
deleted.
7+
By default, Symfony stores the session data in files in the cache
8+
directory ``%kernel.cache_dir%/sessions``. This means that when you clear
9+
the cache, any current sessions will also be deleted.
10+
11+
.. note::
12+
13+
If the ``session`` configuration key is set to ``~``, Symfony will use the
14+
global PHP ini values for ``session.save_handler`` and associated
15+
``session.save_path`` from ``php.ini``.
16+
17+
.. note::
18+
19+
While the Symfony Full Stack Framework defaults to using the
20+
``session.handler.native_file``, the Symfony Standard Edition is
21+
configured to use PHP's global session settings by default and therefor
22+
sessions will be stored according to the ``session.save_path`` location
23+
and will not be deleted when clearing the cache.
1024

1125
Using a different directory to save session data is one method to ensure
1226
that your current sessions aren't lost when you clear Symfony's cache.
@@ -30,18 +44,34 @@ session directory to ``app/sessions``:
3044
# app/config/config.yml
3145
framework:
3246
session:
47+
handler_id: session.handler.native_file
3348
save_path: "%kernel.root_dir%/sessions"
3449
3550
.. code-block:: xml
3651
3752
<!-- app/config/config.xml -->
38-
<framework:config>
39-
<framework:session save-path="%kernel.root_dir%/sessions" />
40-
</framework:config>
53+
<?xml version="1.0" encoding="UTF-8" ?>
54+
<container xmlns="http://symfony.com/schema/dic/services"
55+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
56+
xmlns:framework="http://symfony.com/schema/dic/symfony"
57+
xsi:schemaLocation="http://symfony.com/schema/dic/services
58+
http://symfony.com/schema/dic/services/services-1.0.xsd
59+
http://symfony.com/schema/dic/symfony
60+
http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"
61+
>
62+
<framework:config>
63+
<framework:session handler-id="session.handler.native_file" />
64+
<framework:session save-path="%kernel.root_dir%/sessions" />
65+
</framework:config>
66+
</container>
4167
4268
.. code-block:: php
4369
4470
// app/config/config.php
4571
$container->loadFromExtension('framework', array(
46-
'session' => array('save-path' => "%kernel.root_dir%/sessions"),
72+
'session' => array(
73+
'handler-id' => 'session.handler.native_file',
74+
'save-path' => '%kernel.root_dir%/sessions',
75+
),
4776
));
77+

reference/constraints/UniqueEntity.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ Consider this example:
217217
218218
<class name="Acme\AdministrationBundle\Entity\Service">
219219
<constraint name="Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity">
220-
<option name="field">
220+
<option name="fields">
221221
<value>host</value>
222222
<value>port</value>
223223
</option>

0 commit comments

Comments
 (0)