Skip to content

Commit 6c87f99

Browse files
committed
Merge branch '2.4' into 2.5
2 parents f913dd7 + 080a769 commit 6c87f99

File tree

6 files changed

+74
-42
lines changed

6 files changed

+74
-42
lines changed

book/internals.rst

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ processing must only occur on the master request).
208208
Events
209209
~~~~~~
210210

211+
.. versionadded:: 2.4
212+
The ``isMasterRequest()`` method was introduced in Symfony 2.4.
213+
Prior, the ``getRequestType()`` method must be used.
214+
211215
Each event thrown by the Kernel is a subclass of
212216
:class:`Symfony\\Component\\HttpKernel\\Event\\KernelEvent`. This means that
213217
each event has access to the same basic information:
@@ -216,22 +220,25 @@ each event has access to the same basic information:
216220
- returns the *type* of the request (``HttpKernelInterface::MASTER_REQUEST``
217221
or ``HttpKernelInterface::SUB_REQUEST``);
218222

223+
* :method:`Symfony\\Component\\HttpKernel\\Event\\KernelEvent::isMasterRequest`
224+
- checks if it is a master request;
225+
219226
* :method:`Symfony\\Component\\HttpKernel\\Event\\KernelEvent::getKernel`
220227
- returns the Kernel handling the request;
221228

222229
* :method:`Symfony\\Component\\HttpKernel\\Event\\KernelEvent::getRequest`
223230
- returns the current ``Request`` being handled.
224231

225-
``getRequestType()``
226-
....................
232+
``isMasterRequest()``
233+
.....................
227234

228-
The ``getRequestType()`` method allows listeners to know the type of the
235+
The ``isMasterRequest()`` method allows listeners to check the type of the
229236
request. For instance, if a listener must only be active for master requests,
230237
add the following code at the beginning of your listener method::
231238

232239
use Symfony\Component\HttpKernel\HttpKernelInterface;
233240

234-
if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
241+
if (!$event->isMasterRequest()) {
235242
// return immediately
236243
return;
237244
}

book/routing.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ The route is simple:
7171
The path defined by the ``blog_show`` route acts like ``/blog/*`` where
7272
the wildcard is given the name ``slug``. For the URL ``/blog/my-blog-post``,
7373
the ``slug`` variable gets a value of ``my-blog-post``, which is available
74-
for you to use in your controller (keep reading).
74+
for you to use in your controller (keep reading). The ``blog_show`` is the
75+
internal name of the route, which doesn't have any meaning yet and just needs
76+
to be unique. Later, you'll use it to generate URLs.
7577

7678
The ``_controller`` parameter is a special key that tells Symfony which controller
7779
should be executed when a URL matches this route. The ``_controller`` string

components/http_kernel/introduction.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -665,12 +665,16 @@ argument as follows::
665665
$response = $kernel->handle($request, HttpKernelInterface::SUB_REQUEST);
666666
// do something with this response
667667

668+
.. versionadded:: 2.4
669+
The ``isMasterRequest()`` method was introduced in Symfony 2.4.
670+
Prior, the ``getRequestType()`` method must be used.
671+
668672
This creates another full request-response cycle where this new ``Request`` is
669673
transformed into a ``Response``. The only difference internally is that some
670674
listeners (e.g. security) may only act upon the master request. Each listener
671675
is passed some sub-class of :class:`Symfony\\Component\\HttpKernel\\Event\\KernelEvent`,
672-
whose :method:`Symfony\\Component\\HttpKernel\\Event\\KernelEvent::getRequestType`
673-
can be used to figure out if the current request is a "master" or "sub" request.
676+
whose :method:`Symfony\\Component\\HttpKernel\\Event\\KernelEvent::isMasterRequest`
677+
can be used to check if the current request is a "master" or "sub" request.
674678

675679
For example, a listener that only needs to act on the master request may
676680
look like this::
@@ -680,7 +684,7 @@ look like this::
680684

681685
public function onKernelRequest(GetResponseEvent $event)
682686
{
683-
if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
687+
if (!$event->isMasterRequest()) {
684688
return;
685689
}
686690

components/security/authentication.rst

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -237,20 +237,34 @@ method of the password encoder factory is called with the user object as
237237
its first argument, it will return an encoder of type :class:`Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface`
238238
which should be used to encode this user's password::
239239

240-
// fetch a user of type Acme\Entity\LegacyUser
241-
$user = ...
240+
// a Acme\Entity\LegacyUser instance
241+
$user = ...;
242+
243+
// the password that was submitted, e.g. when registering
244+
$plainPassword = ...;
242245

243246
$encoder = $encoderFactory->getEncoder($user);
244247

245248
// will return $weakEncoder (see above)
249+
$encodedPassword = $encoder->encodePassword($plainPassword, $user->getSalt());
250+
251+
$user->setPassword($encodedPassword);
246252

247-
$encodedPassword = $encoder->encodePassword($password, $user->getSalt());
253+
// ... save the user
248254

249-
// check if the password is valid:
255+
Now, when you want to check if the submitted password (e.g. when trying to log
256+
in) is correct, you can use::
257+
258+
// fetch the Acme\Entity\LegacyUser
259+
$user = ...;
260+
261+
// the submitted password, e.g. from the login form
262+
$plainPassword = ...;
250263

251264
$validPassword = $encoder->isPasswordValid(
252-
$user->getPassword(),
253-
$password,
254-
$user->getSalt());
265+
$user->getPassword(), // the encoded password
266+
$plainPassword, // the submitted password
267+
$user->getSalt()
268+
);
255269

256270
.. _`CVE-2013-5750`: http://symfony.com/blog/cve-2013-5750-security-issue-in-fosuserbundle-login-form

cookbook/service_container/event_listener.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ using a special "tag":
100100
Request events, checking types
101101
------------------------------
102102

103+
.. versionadded:: 2.4
104+
The ``isMasterRequest()`` method was introduced in Symfony 2.4.
105+
Prior, the ``getRequestType()`` method must be used.
106+
103107
A single page can make several requests (one master request, and then multiple
104108
sub-requests), which is why when working with the ``KernelEvents::REQUEST``
105109
event, you might need to check the type of the request. This can be easily
@@ -115,7 +119,7 @@ done as follow::
115119
{
116120
public function onKernelRequest(GetResponseEvent $event)
117121
{
118-
if (HttpKernel::MASTER_REQUEST != $event->getRequestType()) {
122+
if (!$event->isMasterRequest()) {
119123
// don't do anything if it's not the master request
120124
return;
121125
}

cookbook/workflow/new_project_git.rst

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,51 +20,51 @@ Initial Project Setup
2020
To get started, you'll need to download Symfony and initialize your local
2121
git repository:
2222

23-
1. Download the `Symfony2 Standard Edition`_ without vendors.
23+
#. Download the `Symfony2 Standard Edition`_ using Composer:
2424

25-
2. Unzip/untar the distribution. It will create a folder called Symfony with
26-
your new project structure, config files, etc. Rename it to whatever you like.
27-
28-
3. Create a new file called ``.gitignore`` at the root of your new project
29-
(e.g. next to the ``composer.json`` file) and paste the following into it. Files
30-
matching these patterns will be ignored by Git:
31-
32-
.. code-block:: text
33-
34-
/web/bundles/
35-
/app/bootstrap*
36-
/app/cache/*
37-
/app/logs/*
38-
/vendor/
39-
/app/config/parameters.yml
25+
.. code-block:: bash
4026
41-
.. tip::
27+
$ php composer.phar create-project symfony/framework-standard-edition path/ ~2.3
4228
43-
You may also want to create a .gitignore file that can be used system-wide,
44-
in which case, you can find more information here: `Github .gitignore`_
45-
This way you can exclude files/folders often used by your IDE for all of your projects.
29+
Composer will now download the Standard Distribution along with all of the
30+
required vendor libraries. For more information about downloading Symfony using
31+
Composer, see `Installing Symfony using Composer`_.
4632

47-
4. Initialize your Git repository:
33+
#. Initialize your Git repository:
4834

4935
.. code-block:: bash
5036
5137
$ git init
5238
53-
5. Add all of the initial files to Git:
39+
#. Add all of the initial files to Git:
5440

5541
.. code-block:: bash
5642
5743
$ git add .
5844
59-
6. Create an initial commit with your started project:
45+
.. tip::
46+
47+
As you might have noticed, not all files that were downloaded by Composer in step 1,
48+
have been staged for commit by Git. Certain files and folders, such as the project's
49+
dependencies (which are managed by Composer), ``parameters.yml`` (which contains sensitive
50+
information such as database credentials), log and cache files and dumped assets (which are
51+
created automatically by your project), should not be committed in Git. To help you prevent
52+
committing those files and folders by accident, the Standard Distribution comes with a
53+
file called ``.gitignore``, which contains a list of files and folders that Git should
54+
ignore.
55+
56+
.. tip::
57+
58+
You may also want to create a ``.gitignore`` file that can be used system-wide.
59+
This allows you to exclude files/folders for all your projects that are created by
60+
your IDE or operating system. For details, see `Github .gitignore`_.
61+
62+
#. Create an initial commit with your started project:
6063

6164
.. code-block:: bash
6265
6366
$ git commit -m "Initial commit"
6467
65-
7. Finally, download all of the third-party vendor libraries by
66-
executing Composer. For details, see :ref:`installation-updating-vendors`.
67-
6868
At this point, you have a fully-functional Symfony2 project that's correctly
6969
committed to Git. You can immediately begin development, committing the new
7070
changes to your Git repository.
@@ -111,6 +111,7 @@ manage this is `Gitolite`_.
111111

112112
.. _`Git`: http://git-scm.com/
113113
.. _`Symfony2 Standard Edition`: http://symfony.com/download
114+
.. _`Installing Symfony using Composer`: http://symfony.com/doc/current/book/installation.html#option-1-composer
114115
.. _`git submodules`: http://git-scm.com/book/en/Git-Tools-Submodules
115116
.. _`GitHub`: https://github.com/
116117
.. _`barebones repository`: http://git-scm.com/book/en/Git-Basics-Getting-a-Git-Repository

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy