Skip to content

Commit 2cf4eb1

Browse files
committed
Merge branch '4.1'
* 4.1: Replace more occurrences of Controller by AbstractController Fixed a missing AbstractController occurrence Update page_creation.rst the product category must be nullable Added the versionadded directive remove reference to Assetic [Encore] Fix vue-loader installation Add section about anonymous services in YAML update the serializer cache description render versionadded directive outside the code block remove remaining AppBundle references Update routing.rst
2 parents 080d3f2 + e353f66 commit 2cf4eb1

File tree

14 files changed

+104
-70
lines changed

14 files changed

+104
-70
lines changed

controller.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ and many others that you'll learn about next.
120120
Generating URLs
121121
~~~~~~~~~~~~~~~
122122

123-
The :method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\ControllerTrait::generateUrl`
123+
The :method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController::generateUrl`
124124
method is just a helper method that generates the URL for a given route::
125125

126126
$url = $this->generateUrl('app_lucky_number', array('max' => 10));
@@ -328,7 +328,7 @@ special type of exception::
328328
return $this->render(...);
329329
}
330330

331-
The :method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\ControllerTrait::createNotFoundException`
331+
The :method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController::createNotFoundException`
332332
method is just a shortcut to create a special
333333
:class:`Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException`
334334
object, which ultimately triggers a 404 HTTP response inside Symfony.
@@ -581,7 +581,7 @@ the :phpfunction:`json_encode` function is used.
581581
Streaming File Responses
582582
~~~~~~~~~~~~~~~~~~~~~~~~
583583

584-
You can use the :method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::file`
584+
You can use the :method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController::file`
585585
helper to serve a file from inside a controller::
586586

587587
public function download()

controller/forwarding.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ How to Forward Requests to another Controller
55
=============================================
66

77
Though not very common, you can also forward to another controller internally
8-
with the :method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::forward`
8+
with the :method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController::forward`
99
method. Instead of redirecting the user's browser, this makes an "internal"
1010
sub-request and calls the defined controller. The ``forward()`` method returns
1111
the :class:`Symfony\\Component\\HttpFoundation\\Response` object that is returned

doctrine/associations.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ the ``Product`` entity (and getter & setter methods):
146146
147147
/**
148148
* @ORM\ManyToOne(targetEntity="App\Entity\Category", inversedBy="products")
149-
* @ORM\JoinColumn(nullable=false)
150149
*/
151150
private $category;
152151
@@ -155,7 +154,7 @@ the ``Product`` entity (and getter & setter methods):
155154
return $this->category;
156155
}
157156
158-
public function setCategory(Category $category): self
157+
public function setCategory(?Category $category): self
159158
{
160159
$this->category = $category;
161160

frontend.rst

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,6 @@ Full API
7777

7878
* `Full API`_: https://github.com/symfony/webpack-encore/blob/master/index.js
7979

80-
Assetic
81-
-------
82-
83-
Assetic is a pure PHP library that helps to process & optimize your assets (similar
84-
to Encore). Even though we recommend using Encore, Assetic still works great. For
85-
a comparison, see :doc:`/frontend/encore/versus-assetic`.
86-
8780
For more about Assetic, see :doc:`/frontend/assetic`.
8881

8982
Other Front-End Articles
@@ -93,6 +86,7 @@ Other Front-End Articles
9386
:hidden:
9487
:glob:
9588

89+
frontend/assetic
9690
frontend/encore/installation
9791
frontend/encore/simple-example
9892
frontend/encore/*

frontend/encore/vuejs.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Want to use `Vue.js`_? No problem! First, install Vue and some dependencies:
55

66
.. code-block:: terminal
77
8-
$ yarn add --dev vue vue-loader vue-template-compiler
8+
$ yarn add --dev vue vue-loader@^14 vue-template-compiler
99
1010
Then, activate the ``vue-loader`` in ``webpack.config.js``:
1111

page_creation.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,17 +220,17 @@ First, install Twig:
220220
$ composer require symfony/twig-bundle
221221
222222
Second, make sure that ``LuckyController`` extends Symfony's base
223-
:class:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller` class:
223+
:class:`Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController` class:
224224

225225
.. code-block:: diff
226226
227227
// src/Controller/LuckyController.php
228228
229229
// ...
230-
+ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
230+
+ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
231231
232232
- class LuckyController
233-
+ class LuckyController extends Controller
233+
+ class LuckyController extends AbstractController
234234
{
235235
// ...
236236
}
@@ -241,7 +241,7 @@ variable so you can use it in Twig::
241241
// src/Controller/LuckyController.php
242242

243243
// ...
244-
class LuckyController extends Controller
244+
class LuckyController extends AbstractController
245245
{
246246
/**
247247
* @Route("/lucky/number")

reference/configuration/framework.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1822,6 +1822,8 @@ the ``dev`` environment).
18221822
given the adapter they are based on. Internally, a pool wraps the definition
18231823
of an adapter.
18241824

1825+
.. _reference-cache-systen:
1826+
18251827
system
18261828
......
18271829

routing.rst

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ like ``/blog/my-post`` or ``/blog/all-about-symfony``:
3737
// src/Controller/BlogController.php
3838
namespace App\Controller;
3939
40-
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
40+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
4141
use Symfony\Component\Routing\Annotation\Route;
4242
43-
class BlogController extends Controller
43+
class BlogController extends AbstractController
4444
{
4545
/**
4646
* Matches /blog exactly
@@ -154,10 +154,10 @@ Symfony provides a handy way to declare localized routes without duplication.
154154
// src/Controller/BlogController.php
155155
namespace App\Controller;
156156
157-
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
157+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
158158
use Symfony\Component\Routing\Annotation\Route;
159159
160-
class CompanyController extends Controller
160+
class CompanyController extends AbstractController
161161
{
162162
/**
163163
* @Route({
@@ -252,10 +252,10 @@ To fix this, add a *requirement* that the ``{page}`` wildcard can *only* match n
252252
// src/Controller/BlogController.php
253253
namespace App\Controller;
254254
255-
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
255+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
256256
use Symfony\Component\Routing\Annotation\Route;
257257
258-
class BlogController extends Controller
258+
class BlogController extends AbstractController
259259
{
260260
/**
261261
* @Route("/blog/{page}", name="blog_list", requirements={"page"="\d+"})
@@ -340,10 +340,10 @@ concise, but it can decrease route readability when requirements are complex:
340340
// src/Controller/BlogController.php
341341
namespace App\Controller;
342342
343-
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
343+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
344344
use Symfony\Component\Routing\Annotation\Route;
345345
346-
class BlogController extends Controller
346+
class BlogController extends AbstractController
347347
{
348348
/**
349349
* @Route("/blog/{page<\d+>}", name="blog_list")
@@ -416,10 +416,10 @@ So how can you make ``blog_list`` once again match when the user visits
416416
// src/Controller/BlogController.php
417417
namespace App\Controller;
418418
419-
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
419+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
420420
use Symfony\Component\Routing\Annotation\Route;
421421
422-
class BlogController extends Controller
422+
class BlogController extends AbstractController
423423
{
424424
/**
425425
* @Route("/blog/{page}", name="blog_list", requirements={"page"="\d+"})
@@ -500,10 +500,10 @@ placeholder:
500500
// src/Controller/BlogController.php
501501
namespace App\Controller;
502502
503-
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
503+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
504504
use Symfony\Component\Routing\Annotation\Route;
505505
506-
class BlogController extends Controller
506+
class BlogController extends AbstractController
507507
{
508508
/**
509509
* @Route("/blog/{page<\d+>?1}", name="blog_list")
@@ -596,7 +596,7 @@ With all of this in mind, check out this advanced example:
596596
// src/Controller/ArticleController.php
597597
598598
// ...
599-
class ArticleController extends Controller
599+
class ArticleController extends AbstractController
600600
{
601601
/**
602602
* @Route(
@@ -781,7 +781,7 @@ To generate a URL, you need to specify the name of the route (e.g. ``blog_show``
781781
and any wildcards (e.g. ``slug = my-blog-post``) used in the path for that
782782
route. With this information, any URL can easily be generated::
783783

784-
class MainController extends Controller
784+
class MainController extends AbstractController
785785
{
786786
public function show($slug)
787787
{

security/csrf.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ token and store it as a hidden field of the form:
279279
</form>
280280
281281
Then, get the value of the CSRF token in the controller action and use the
282-
:method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::isCsrfTokenValid`
282+
:method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController::isCsrfTokenValid`
283283
to check its validity::
284284

285285
use Symfony\Component\HttpFoundation\Request;

serializer.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,10 @@ stored in one of the following locations:
147147
Configuring the Metadata Cache
148148
------------------------------
149149

150-
The metadata for the serializer is automatically cached. To configure the cache,
151-
configure the ``framework.cache.pools`` key in ``config/packages/framework.yaml``.
150+
The metadata for the serializer is automatically cached to enhance application
151+
performance. By default, the serializer uses the ``cache.system`` cache pool
152+
which is configured using the :ref:`cache.system <reference-cache-systen>`
153+
option.
152154

153155
Enabling a Name Converter
154156
-------------------------

service_container/alias_private.rst

Lines changed: 61 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,10 @@ Anonymous Services
151151

152152
.. note::
153153

154-
Anonymous services are only supported by the XML configuration format.
154+
Anonymous services are only supported by the XML and YAML configuration formats.
155+
156+
.. versionadded:: 3.3
157+
The feature to configure anonymous services in YAML was introduced in Symfony 3.3.
155158

156159
In some cases, you may want to prevent a service being used as a dependency of
157160
other services. This can be achieved by creating an anonymous service. These
@@ -160,23 +163,63 @@ created where they are used.
160163

161164
The following example shows how to inject an anonymous service into another service:
162165

163-
.. code-block:: xml
164-
165-
<!-- app/config/services.xml -->
166-
<?xml version="1.0" encoding="UTF-8" ?>
167-
<container xmlns="http://symfony.com/schema/dic/services"
168-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
169-
xsi:schemaLocation="http://symfony.com/schema/dic/services
170-
http://symfony.com/schema/dic/services/services-1.0.xsd">
171-
172-
<services>
173-
<service id="foo" class="App\Foo">
174-
<argument type="service">
175-
<service class="App\AnonymousBar" />
176-
</argument>
177-
</service>
178-
</services>
179-
</container>
166+
.. configuration-block::
167+
168+
.. code-block:: yaml
169+
170+
# app/config/services.yaml
171+
services:
172+
App\Foo:
173+
arguments:
174+
- !service
175+
class: App\AnonymousBar
176+
177+
.. code-block:: xml
178+
179+
<!-- app/config/services.xml -->
180+
<?xml version="1.0" encoding="UTF-8" ?>
181+
<container xmlns="http://symfony.com/schema/dic/services"
182+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
183+
xsi:schemaLocation="http://symfony.com/schema/dic/services
184+
http://symfony.com/schema/dic/services/services-1.0.xsd">
185+
186+
<services>
187+
<service id="foo" class="App\Foo">
188+
<argument type="service">
189+
<service class="App\AnonymousBar" />
190+
</argument>
191+
</service>
192+
</services>
193+
</container>
194+
195+
Using an anonymous service as a factory looks like this:
196+
197+
.. configuration-block::
198+
199+
.. code-block:: yaml
200+
201+
# app/config/services.yaml
202+
services:
203+
App\Foo:
204+
factory: [ !service { class: App\FooFactory }, 'constructFoo' ]
205+
206+
.. code-block:: xml
207+
208+
<!-- app/config/services.xml -->
209+
<?xml version="1.0" encoding="UTF-8" ?>
210+
<container xmlns="http://symfony.com/schema/dic/services"
211+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
212+
xsi:schemaLocation="http://symfony.com/schema/dic/services
213+
http://symfony.com/schema/dic/services/services-1.0.xsd">
214+
215+
<services>
216+
<service id="foo" class="App\Foo">
217+
<factory method="constructFoo">
218+
<service class="App\FooFactory"/>
219+
</factory>
220+
</service>
221+
</services>
222+
</container>
180223
181224
Deprecating Services
182225
--------------------

service_container/service_decoration.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ the original service is lost:
3131
<services>
3232
<service id="App\Mailer" />
3333
34-
<!-- this replaces the old AppBundle\Mailer definition with the new
34+
<!-- this replaces the old App\Mailer definition with the new
3535
one, the old definition is lost -->
3636
<service id="App\Mailer" class="App\DecoratingMailer" />
3737
</services>
@@ -45,7 +45,7 @@ the original service is lost:
4545
4646
$container->register(Mailer::class);
4747
48-
// this replaces the old AppBundle\Mailer definition with the new one, the
48+
// this replaces the old App\Mailer definition with the new one, the
4949
// old definition is lost
5050
$container->register(Mailer::class, DecoratingMailer::class);
5151

0 commit comments

Comments
 (0)