Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 755f231

Browse filesBrowse files
committed
Merge branch '4.0'
* 4.0: Update collection.rst Mention that PSR-1 doesn't recommend CamelCase or anything else Fixed the XML and PHP config instead of the YAML config Use controller method injection instead of the constructor Add missing references Updated documentation to reflect best practice of using Dependency Injection over Container. Includes changes from PR #8985 Removed "Accessing the Container Directly" minor #8091 Update js-datepicker usage for new jQuery UI (AdrianBorodziuk, javiereguiluz) minor #8983 cross-reference console command testing from testing guide (dbu) Fix YAML config bug Removed invalid examples commands are automatically registered in symfony full stack update forms.rst
2 parents 935dd43 + 43ac526 commit 755f231
Copy full SHA for 755f231

File tree

10 files changed

+42
-43
lines changed
Filter options

10 files changed

+42
-43
lines changed

‎best_practices/security.rst

Copy file name to clipboardExpand all lines: best_practices/security.rst
+21-5Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,20 @@ more advanced use-case, you can always do the same security check in PHP:
238238
// equivalent code without using the "denyAccessUnlessGranted()" shortcut:
239239
//
240240
// use Symfony\Component\Security\Core\Exception\AccessDeniedException;
241+
// use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface
242+
//
243+
// ...
244+
//
245+
// public function __construct(AuthorizationCheckerInterface $authorizationChecker) {
246+
// $this->authorizationChecker = $authorizationChecker;
247+
// }
248+
//
241249
// ...
242250
//
243-
// if (!$this->get('security.authorization_checker')->isGranted('edit', $post)) {
251+
// if (!$this->authorizationChecker->isGranted('edit', $post)) {
244252
// throw $this->createAccessDeniedException();
245253
// }
246-
254+
//
247255
// ...
248256
}
249257
@@ -357,14 +365,22 @@ via the even easier shortcut in a controller:
357365
358366
$this->denyAccessUnlessGranted('edit', $post);
359367
360-
// or without the shortcut:
361-
//
362368
// use Symfony\Component\Security\Core\Exception\AccessDeniedException;
369+
// use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface
370+
//
363371
// ...
364372
//
365-
// if (!$this->get('security.authorization_checker')->isGranted('edit', $post)) {
373+
// public function __construct(AuthorizationCheckerInterface $authorizationChecker) {
374+
// $this->authorizationChecker = $authorizationChecker;
375+
// }
376+
//
377+
// ...
378+
//
379+
// if (!$this->authorizationChecker->isGranted('edit', $post)) {
366380
// throw $this->createAccessDeniedException();
367381
// }
382+
//
383+
// ...
368384
}
369385
370386
Learn More

‎components/serializer.rst

Copy file name to clipboardExpand all lines: components/serializer.rst
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,9 @@ CamelCase to snake_case
459459
~~~~~~~~~~~~~~~~~~~~~~~
460460

461461
In many formats, it's common to use underscores to separate words (also known
462-
as snake_case). However, PSR-1 specifies that the preferred style for PHP
463-
properties and methods is CamelCase.
462+
as snake_case). However, in Symfony applications is common to use CamelCase to
463+
name properties (even though the `PSR-1 standard`_ doesn't recommend any
464+
specific case for property names).
464465

465466
Symfony provides a built-in name converter designed to transform between
466467
snake_case and CamelCased styles during serialization and deserialization
@@ -994,6 +995,7 @@ Learn more
994995
A popular alternative to the Symfony Serializer Component is the third-party
995996
library, `JMS serializer`_ (released under the Apache license, so incompatible with GPLv2 projects).
996997

998+
.. _`PSR-1 standard`: http://www.php-fig.org/psr/psr-1/
997999
.. _`JMS serializer`: https://github.com/schmittjoh/serializer
9981000
.. _Packagist: https://packagist.org/packages/symfony/serializer
9991001
.. _RFC3339: https://tools.ietf.org/html/rfc3339#section-5.8

‎console.rst

Copy file name to clipboardExpand all lines: console.rst
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,6 @@ you can extend your test from
299299
$kernel->boot();
300300

301301
$application = new Application($kernel);
302-
$application->add(new CreateUserCommand());
303302

304303
$command = $application->find('app:create-user');
305304
$commandTester = new CommandTester($command);

‎controller.rst

Copy file name to clipboardExpand all lines: controller.rst
-27Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -290,33 +290,6 @@ in your controllers.
290290

291291
For more information about services, see the :doc:`/service_container` article.
292292

293-
.. _controller-access-services-directly:
294-
295-
Accessing the Container Directly
296-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
297-
298-
If you extend the base ``Controller`` class, you can access :ref:`public services <container-public>`
299-
via the :method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::get`
300-
method. Here are several common services you might need::
301-
302-
$templating = $this->get('templating');
303-
304-
$router = $this->get('router');
305-
306-
$mailer = $this->get('mailer');
307-
308-
// you can also fetch parameters
309-
$someParameter = $this->getParameter('some_parameter');
310-
311-
If you receive an error like:
312-
313-
.. code-block:: text
314-
315-
You have requested a non-existent service "my_service_id"
316-
317-
Check to make sure the service exists (use :ref:`debug:container <container-debug-container>`)
318-
and that it's :ref:`public <container-public>`.
319-
320293
.. index::
321294
single: Controller; Managing errors
322295
single: Controller; 404 pages

‎doctrine/multiple_entity_managers.rst

Copy file name to clipboardExpand all lines: doctrine/multiple_entity_managers.rst
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,14 @@ the default entity manager (i.e. ``default``) is returned::
231231

232232
// ...
233233

234+
use Doctrine\ORM\EntityManagerInterface;
235+
234236
class UserController extends Controller
235237
{
236-
public function indexAction()
238+
public function indexAction(EntityManagerInterface $em)
237239
{
238-
// All 3 return the "default" entity manager
240+
// These methods also return the default entity manager, but it's preferred
241+
// to get it by inyecting EntityManagerInterface in the action method
239242
$em = $this->getDoctrine()->getManager();
240243
$em = $this->getDoctrine()->getManager('default');
241244
$em = $this->get('doctrine.orm.default_entity_manager');

‎event_dispatcher.rst

Copy file name to clipboardExpand all lines: event_dispatcher.rst
+2-4Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,7 @@ using a special "tag":
9191
http://symfony.com/schema/dic/services/services-1.0.xsd">
9292
9393
<services>
94-
<service id="app.exception_listener"
95-
class="App\EventListener\ExceptionListener">
96-
94+
<service id="AppBundle\EventListener\ExceptionListener">
9795
<tag name="kernel.event_listener" event="kernel.exception" />
9896
</service>
9997
</services>
@@ -105,7 +103,7 @@ using a special "tag":
105103
use App\EventListener\ExceptionListener;
106104
107105
$container
108-
->register('app.exception_listener', ExceptionListener::class)
106+
->autowire(ExceptionListener::class)
109107
->addTag('kernel.event_listener', array('event' => 'kernel.exception'))
110108
;
111109

‎forms.rst

Copy file name to clipboardExpand all lines: forms.rst
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,12 @@ valid, but whether or not the ``$task`` object is valid after the form has
317317
applied the submitted data to it. Calling ``$form->isValid()`` is a shortcut
318318
that asks the ``$task`` object whether or not it has valid data.
319319

320+
Before using validation, add support for it in your application:
321+
322+
.. code-block:: terminal
323+
324+
$ composer require validator
325+
320326
Validation is done by adding a set of rules (called constraints) to a class. To
321327
see this in action, add validation constraints so that the ``task`` field cannot
322328
be empty and the ``dueDate`` field cannot be empty and must be a valid \DateTime

‎reference/forms/types/collection.rst

Copy file name to clipboardExpand all lines: reference/forms/types/collection.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ type::
334334
entry_type
335335
~~~~~~~~~~
336336

337-
**type**: ``string`` or :class:`Symfony\\Component\\Form\\FormTypeInterface` **required**
337+
**type**: ``string`` or :class:`Symfony\\Component\\Form\\FormTypeInterface` **default**: Symfony\\Component\\Form\\Extension\\Core\\Type\\TextType
338338

339339
This is the field type for each item in this collection (e.g. ``TextType``,
340340
``ChoiceType``, etc). For example, if you have an array of email addresses,

‎routing.rst

Copy file name to clipboardExpand all lines: routing.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ Generating URLs with Query Strings
576576
The ``generate()`` method takes an array of wildcard values to generate the URI.
577577
But if you pass extra ones, they will be added to the URI as a query string::
578578

579-
$this->get('router')->generate('blog', array(
579+
$this->router->generate('blog', array(
580580
'page' => 2,
581581
'category' => 'Symfony'
582582
));

‎service_container.rst

Copy file name to clipboardExpand all lines: service_container.rst
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,8 @@ Learn more
980980
:maxdepth: 1
981981
:glob:
982982

983+
/service_container/*
984+
983985
.. _`service-oriented architecture`: https://en.wikipedia.org/wiki/Service-oriented_architecture
984986
.. _`Symfony Standard Edition (version 3.3) services.yaml`: https://github.com/symfony/symfony-standard/blob/3.3/app/config/services.yml
985987
.. _`glob pattern`: https://en.wikipedia.org/wiki/Glob_(programming)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.