Skip to content

Commit ee7f14f

Browse files
committed
Merge branch '2.8'
* 2.8: Ensure that the entity is updated. Update lazy_services.rst Update templating.rst Additional little check to show how we're assumign the User object is the User entity Moved mongodb article and cleanup Fixing remaining reference of old emplacement of pdo_session_storage page due to the rebase Move some articles from wrong sections, updated indexs Move some articles from wrong sections [symfony#5374] Add deprecation notice in 2.7 fix YAML syntax highlighting Improve and simplify the contributing instructions about tests Some fixes for bundle best practices Fix Major upgrade article for 2.7.1 changes [symfony#5413] Backporting changes to 2.3 Added caution notes about the deprecation of container scopes
2 parents fceaa9f + eafdb8c commit ee7f14f

27 files changed

+116
-108
lines changed

Diff for: book/templating.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -1224,7 +1224,7 @@ automatically:
12241224

12251225
.. versionadded:: 2.6
12261226
The global ``app.security`` variable (or the ``$app->getSecurity()``
1227-
method in PHP templates) is deprecated as of Symfony 2.6. Use ``app.user``
1227+
method in PHP templates) is deprecated as of Symfony 2.6. Use ``app.user``
12281228
(``$app->getUser()``) and ``is_granted()`` (``$view['security']->isGranted()``)
12291229
instead.
12301230

@@ -1595,16 +1595,16 @@ is ``true``. By default this means that the variables will be dumped in the
15951595
Syntax Checking
15961596
---------------
15971597

1598-
You can check for syntax errors in Twig templates using the ``twig:lint``
1598+
You can check for syntax errors in Twig templates using the ``lint:twig``
15991599
console command:
16001600

16011601
.. code-block:: bash
16021602
16031603
# You can check by filename:
1604-
$ php app/console twig:lint app/Resources/views/article/recent_list.html.twig
1604+
$ php app/console lint:twig app/Resources/views/article/recent_list.html.twig
16051605
16061606
# or by directory:
1607-
$ php app/console twig:lint app/Resources/views
1607+
$ php app/console lint:twig app/Resources/views
16081608
16091609
.. _template-formats:
16101610

Diff for: components/dependency_injection/lazy_services.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ the `ProxyManager bridge`_:
4040

4141
.. code-block:: bash
4242
43-
$ php composer.phar require ocramius/proxy-manager:~1.0
43+
$ composer require ocramius/proxy-manager:~1.0
4444
4545
Afterwards compile your container and check to make sure that you get
4646
a proxy for your lazy services.

Diff for: contributing/code/tests.rst

+22-67
Original file line numberDiff line numberDiff line change
@@ -3,54 +3,32 @@
33
Running Symfony Tests
44
=====================
55

6-
Before submitting a :doc:`patch <patches>` for inclusion, you need to run the
7-
Symfony test suite to check that you have not broken anything.
6+
The Symfony project uses a third-party service which automatically runs tests
7+
for any submitted :doc:`patch <patches>`. If the new code breaks any test,
8+
the pull request will show an error message with a link to the full error details.
89

9-
PHPUnit
10-
-------
10+
In any case, it's a good practice to run tests locally before submitting a
11+
:doc:`patch <patches>` for inclusion, to check that you have not broken anything.
1112

12-
To run the Symfony test suite, `install PHPUnit`_ 4.2 (or later) first.
13+
.. _phpunit:
14+
.. _dependencies_optional:
1315

14-
Dependencies (optional)
15-
-----------------------
16+
Before Running the Tests
17+
------------------------
1618

17-
To run the entire test suite, including tests that depend on external
18-
dependencies, Symfony needs to be able to autoload them. By default, they are
19-
autoloaded from ``vendor/`` under the main root directory (see
20-
``autoload.php.dist``).
21-
22-
The test suite needs the following third-party libraries:
23-
24-
* Doctrine
25-
* Swift Mailer
26-
* Twig
27-
* Monolog
28-
29-
To install them all, use `Composer`_:
30-
31-
Step 1: :doc:`Install Composer globally </cookbook/composer>`
32-
33-
Step 2: Install vendors.
19+
To run the Symfony test suite, `install PHPUnit`_ 4.2 (or later) first. Then,
20+
install the external dependencies used during the tests, such as Doctrine, Twig
21+
and Monolog. To do so, :doc:`install Composer </cookbook/composer>` and execute
22+
the following:
3423

3524
.. code-block:: bash
3625
3726
$ composer install
3827
39-
.. note::
40-
41-
Note that the script takes some time to finish.
28+
.. _running:
4229

43-
After installation, you can update the vendors to their latest version with
44-
the follow command:
45-
46-
.. code-block:: bash
47-
48-
$ composer update
49-
50-
Running
51-
-------
52-
53-
First, update the vendors (see above).
30+
Running the Tests
31+
-----------------
5432

5533
Then, run the test suite from the Symfony root directory with the following
5634
command:
@@ -59,40 +37,17 @@ command:
5937
6038
$ phpunit
6139
62-
The output should display ``OK``. If not, you need to figure out what's going on
63-
and if the tests are broken because of your modifications.
40+
The output should display ``OK``. If not, read the reported errors to figure out
41+
what's going on and if the tests are broken because of the new code.
6442

6543
.. tip::
6644

67-
If you want to test a single component type its path after the ``phpunit``
68-
command, e.g.:
45+
The entire Symfony suite can take up to several minutes to complete. If you
46+
want to test a single component, type its path after the ``phpunit`` command,
47+
e.g.:
6948

7049
.. code-block:: bash
7150
7251
$ phpunit src/Symfony/Component/Finder/
7352
74-
.. tip::
75-
76-
Run the test suite before applying your modifications to check that they
77-
run fine on your configuration.
78-
79-
Code Coverage
80-
-------------
81-
82-
If you add a new feature, you also need to check the code coverage by using
83-
the ``coverage-html`` option:
84-
85-
.. code-block:: bash
86-
87-
$ phpunit --coverage-html=cov/
88-
89-
Check the code coverage by opening the generated ``cov/index.html`` page in a
90-
browser.
91-
92-
.. tip::
93-
94-
The code coverage only works if you have Xdebug enabled and all
95-
dependencies installed.
96-
97-
.. _install PHPUnit: https://phpunit.de/manual/current/en/installation.html
98-
.. _`Composer`: https://getcomposer.org/
53+
.. _`install PHPUnit`: https://phpunit.de/manual/current/en/installation.html

Diff for: cookbook/bundles/best_practices.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ class name is ``Acme\BlogBundle\Controller\ContentController``.
146146
All classes and files must follow the :doc:`Symfony coding standards </contributing/code/standards>`.
147147

148148
Some classes should be seen as facades and should be as short as possible, like
149-
Commands, Helpers, Listeners, and Controllers.
149+
Commands, Helpers, Listeners and Controllers.
150150

151151
Classes that connect to the event dispatcher should be suffixed with
152152
``Listener``.
@@ -159,7 +159,7 @@ Vendors
159159
A bundle must not embed third-party PHP libraries. It should rely on the
160160
standard Symfony autoloading instead.
161161

162-
A bundle should not embed third-party libraries written in JavaScript, CSS, or
162+
A bundle should not embed third-party libraries written in JavaScript, CSS or
163163
any other language.
164164

165165
Tests
@@ -175,6 +175,7 @@ the ``Tests/`` directory. Tests should follow the following principles:
175175
* The tests should cover at least 95% of the code base.
176176

177177
.. note::
178+
178179
A test suite must not contain ``AllTests.php`` scripts, but must rely on the
179180
existence of a ``phpunit.xml.dist`` file.
180181

Diff for: cookbook/configuration/index.rst

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ Configuration
99
using_parameters_in_dic
1010
front_controllers_and_kernel
1111
external_parameters
12-
pdo_session_storage
1312
apache_router
1413
web_server_configuration
1514
configuration_organization
16-
mongodb_session_storage

Diff for: cookbook/console/console_command.rst

+5
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ for details.
8282
Getting Services from the Service Container
8383
-------------------------------------------
8484

85+
.. caution::
86+
87+
The "container scopes" concept explained in this section has been deprecated
88+
in Symfony 2.8 and it will be removed in Symfony 3.0.
89+
8590
By using :class:`Symfony\\Bundle\\FrameworkBundle\\Command\\ContainerAwareCommand`
8691
as the base class for the command (instead of the more basic
8792
:class:`Symfony\\Component\\Console\\Command\\Command`), you have access to the

Diff for: cookbook/controller/error_pages.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ before, but also requires a thorough understanding of Symfony internals. Suppose
302302
that your code throws specialized exceptions with a particular meaning to your
303303
application domain.
304304

305-
:doc:`Writing your own event listener </cookbook/service_container/event_listener>`
305+
:doc:`Writing your own event listener </cookbook/event_dispatcher/event_listener>`
306306
for the ``kernel.exception`` event allows you to have a closer look at the exception
307307
and take different actions depending on it. Those actions might include logging
308308
the exception, redirecting the user to another page or rendering specialized

Diff for: cookbook/doctrine/file_uploads.rst

+1
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,7 @@ property, instead of the actual filename::
494494
if (is_file($this->getAbsolutePath())) {
495495
// store the old name to delete after the update
496496
$this->temp = $this->getAbsolutePath();
497+
$this->path = null;
497498
} else {
498499
$this->path = 'initial';
499500
}

Diff for: cookbook/doctrine/index.rst

+2
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ Doctrine
1414
resolve_target_entity
1515
mapping_model_classes
1616
registration_form
17+
pdo_session_storage
18+
mongodb_session_storage
1719
console

Diff for: cookbook/configuration/mongodb_session_storage.rst renamed to cookbook/doctrine/mongodb_session_storage.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ need to change/add some parameters in the main configuration file:
3030
mongo_client:
3131
class: MongoClient
3232
# if using a username and password
33-
arguments: [mongodb://%mongodb_username%:%mongodb_password%@%mongodb_host%:27017]
33+
arguments: ["mongodb://%mongodb_username%:%mongodb_password%@%mongodb_host%:27017"]
3434
# if not using a username and password
35-
arguments: [mongodb://%mongodb_host%:27017]
35+
arguments: ["mongodb://%mongodb_host%:27017"]
3636
session.handler.mongo:
3737
class: Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler
38-
arguments: [@mongo_client, %mongo.session.options%]
38+
arguments: ["@mongo_client", "%mongo.session.options%"]
3939
4040
.. code-block:: xml
4141
@@ -168,4 +168,4 @@ From the `MongoDB shell`_:
168168
db.session.ensureIndex( { "expireAt": 1 }, { expireAfterSeconds: 0 } )
169169
170170
.. _installed and configured a MongoDB server: http://docs.mongodb.org/manual/installation/
171-
.. _MongoDB shell: http://docs.mongodb.org/v2.2/tutorial/getting-started-with-the-mongo-shell/
171+
.. _MongoDB shell: http://docs.mongodb.org/v2.2/tutorial/getting-started-with-the-mongo-shell/

Diff for: cookbook/event_dispatcher/before_after_filters.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Creating an Event Listener
102102

103103
Next, you'll need to create an event listener, which will hold the logic
104104
that you want executed before your controllers. If you're not familiar with
105-
event listeners, you can learn more about them at :doc:`/cookbook/service_container/event_listener`::
105+
event listeners, you can learn more about them at :doc:`/cookbook/event_dispatcher/event_listener`::
106106

107107
// src/AppBundle/EventListener/TokenListener.php
108108
namespace AppBundle\EventListener;

Diff for: cookbook/event_dispatcher/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Event Dispatcher
44
.. toctree::
55
:maxdepth: 2
66

7+
event_listener
78
before_after_filters
89
class_extension
910
method_behavior

Diff for: cookbook/logging/monolog.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ option of your handler to ``rotating_file``:
242242
handlers:
243243
main:
244244
type: rotating_file
245-
path: %kernel.logs_dir%/%kernel.environment%.log
245+
path: "%kernel.logs_dir%/%kernel.environment%.log"
246246
level: debug
247247
# max number of log files to keep
248248
# defaults to zero, which means infinite files

Diff for: cookbook/map.rst.inc

+11-9
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434
* :doc:`/cookbook/configuration/using_parameters_in_dic`
3535
* :doc:`/cookbook/configuration/front_controllers_and_kernel`
3636
* :doc:`/cookbook/configuration/external_parameters`
37-
* :doc:`/cookbook/configuration/pdo_session_storage`
3837
* :doc:`/cookbook/configuration/apache_router`
3938
* :doc:`/cookbook/configuration/web_server_configuration`
4039
* :doc:`/cookbook/configuration/configuration_organization`
41-
* :doc:`/cookbook/configuration/mongodb_session_storage`
40+
* (Doctrine) :doc:`/cookbook/doctrine/pdo_session_storage`
41+
* (Doctrine) :doc:`/cookbook/doctrine/mongodb_session_storage`
4242

4343
* :doc:`/cookbook/console/index`
4444

@@ -78,8 +78,9 @@
7878
* :doc:`/cookbook/doctrine/resolve_target_entity`
7979
* :doc:`/cookbook/doctrine/mapping_model_classes`
8080
* :doc:`/cookbook/doctrine/registration_form`
81+
* :doc:`/cookbook/doctrine/pdo_session_storage`
82+
* :doc:`/cookbook/doctrine/mongodb_session_storage`
8183
* :doc:`/cookbook/doctrine/console`
82-
* (configuration) :doc:`/cookbook/configuration/pdo_session_storage`
8384

8485
* :doc:`/cookbook/email/index`
8586

@@ -95,7 +96,7 @@
9596
* :doc:`/cookbook/event_dispatcher/before_after_filters`
9697
* :doc:`/cookbook/event_dispatcher/class_extension`
9798
* :doc:`/cookbook/event_dispatcher/method_behavior`
98-
* (service container) :doc:`/cookbook/service_container/event_listener`
99+
* :doc:`/cookbook/event_dispatcher/event_listener`
99100

100101
* :doc:`/cookbook/expression/index`
101102

@@ -113,8 +114,8 @@
113114
* :doc:`/cookbook/form/unit_testing`
114115
* :doc:`/cookbook/form/use_empty_data`
115116
* :doc:`/cookbook/form/direct_submit`
116-
* (validation) :doc:`/cookbook/validation/custom_constraint`
117-
* (doctrine) :doc:`/cookbook/doctrine/file_uploads`
117+
* (Validation) :doc:`/cookbook/validation/custom_constraint`
118+
* (Doctrine) :doc:`/cookbook/doctrine/file_uploads`
118119

119120
* :doc:`/cookbook/frontend/index`
120121

@@ -190,9 +191,9 @@
190191

191192
* :doc:`/cookbook/service_container/index`
192193

193-
* :doc:`/cookbook/service_container/event_listener`
194194
* :doc:`/cookbook/service_container/scopes`
195195
* :doc:`/cookbook/service_container/compiler_passes`
196+
* (Event Dispatcher) :doc:`/cookbook/event_dispatcher/event_listener`
196197

197198
* :doc:`/cookbook/session/index`
198199

@@ -201,10 +202,11 @@
201202
* :doc:`/cookbook/session/sessions_directory`
202203
* :doc:`/cookbook/session/php_bridge`
203204
* :doc:`/cookbook/session/limit_metadata_writes`
204-
* (configuration) :doc:`/cookbook/configuration/pdo_session_storage`
205-
* (configuration) :doc:`/cookbook/configuration/mongodb_session_storage`
205+
* (Doctrine) :doc:`/cookbook/doctrine/pdo_session_storage`
206+
* (Doctrine) :doc:`/cookbook/doctrine/mongodb_session_storage`
206207
* :doc:`/cookbook/session/avoid_session_start`
207208

209+
208210
* **PSR-7**
209211

210212
* :doc:`/cookbook/psr7`

Diff for: cookbook/security/voters.rst

+8
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ edit a particular object. Here's an example implementation:
7171
namespace AppBundle\Security\Authorization\Voter;
7272
7373
use Symfony\Component\Security\Core\Authorization\Voter\AbstractVoter;
74+
use AppBundle\Entity\User;
7475
use Symfony\Component\Security\Core\User\UserInterface;
7576
7677
class PostVoter extends AbstractVoter
@@ -95,6 +96,13 @@ edit a particular object. Here's an example implementation:
9596
return false;
9697
}
9798
99+
// double-check that the User object is the expected entity.
100+
// It always will be, unless there is some misconfiguration of the
101+
// security system.
102+
if (!$user instanceof User) {
103+
throw new \LogicException('The user is somehow not our User class!');
104+
}
105+
98106
switch($attribute) {
99107
case self::VIEW:
100108
// the data object could have for example a method isPrivate()

Diff for: cookbook/service_container/index.rst

-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@ Service Container
44
.. toctree::
55
:maxdepth: 2
66

7-
event_listener
87
scopes
98
compiler_passes

Diff for: cookbook/service_container/scopes.rst

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
How to Work with Scopes
55
=======================
66

7+
.. caution::
8+
9+
The "container scopes" concept explained in this article has been deprecated
10+
in Symfony 2.8 and it will be removed in Symfony 3.0.
11+
712
This article is all about scopes, a somewhat advanced topic related to the
813
:doc:`/book/service_container`. If you've ever gotten an error mentioning
914
"scopes" when creating services, then this article is for you.

0 commit comments

Comments
 (0)