Skip to content

Commit da83ca4

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: (30 commits) [#7560] remove unused use statements Resolving $this usage outside a class on form.rst Fix some odd English in the PDOSessionHandler docs Fix typo Add the description for the HTTP status because it's not that common Update exception code status [#7592] some minor tweaks Fix link for Twig Extensions documentation Update framework.rst [Fix esi tag] Update render_without_controller.rst Update matchers.rst Update matchers.rst Update locale_sticky_session.rst Update framework.rst Update import.rst Update load_balancer_reverse_proxy.rst Moved the requirements file [#7509] add missing references Added a mention to APCu Polyfill in the performance article [#7497] minor rewording ...
2 parents 2d7ea6b + fb70182 commit da83ca4

28 files changed

+173
-93
lines changed

.platform.app.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,5 @@ hooks:
5656
# Platform.sh currently sets PIP_USER=1.
5757
export PIP_USER=
5858
pip install pip==9.0.1 wheel==0.29.0
59-
pip install -r requirements.txt
59+
pip install -r _build/.requirements.txt
6060
make -C _build html
File renamed without changes.

_build/make.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ REM Command file for Sphinx documentation
55
if "%SPHINXBUILD%" == "" (
66
set SPHINXBUILD=sphinx-build
77
)
8-
set BUILDDIR=_build
9-
set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
8+
set BUILDDIR=.
9+
set ALLSPHINXOPTS=-c %BUILDDIR% -d %BUILDDIR%/doctrees %SPHINXOPTS% ..
1010
set I18NSPHINXOPTS=%SPHINXOPTS% .
1111
if NOT "%PAPER%" == "" (
1212
set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%

assetic/jpeg_optimize.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,4 +308,4 @@ file:
308308
`LiipImagineBundle`_ community bundle.
309309

310310
.. _`Jpegoptim`: http://www.kokkonen.net/tjko/projects.html
311-
.. _`LiipImagineBundle`: http://knpbundles.com/liip/LiipImagineBundle
311+
.. _`LiipImagineBundle`: https://github.com/liip/LiipImagineBundle

best_practices/configuration.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,31 @@ whereas they cannot access the container parameters:
153153
The only notable disadvantage of using constants for this kind of configuration
154154
values is that you cannot redefine them easily in your tests.
155155

156+
Parameter Naming
157+
----------------
158+
159+
.. best-practice::
160+
161+
The name of your configuration parameters should be as short as possible and
162+
should include a common prefix for the entire application.
163+
164+
Using ``app.`` as the prefix of your parameters is a common practice to avoid
165+
collisions with Symfony and third-party bundles/libraries parameters. Then, use
166+
just one or two words to describe the purpose of the parameter:
167+
168+
.. code-block:: yaml
169+
170+
# app/config/config.yml
171+
parameters:
172+
# don't do this: 'dir' is too generic and it doesn't convey any meaning
173+
app.dir: '...'
174+
# do this: short but easy to understand names
175+
app.contents_dir: '...'
176+
# it's OK to use dots, underscores, dashes or nothing, but always
177+
# be consistent and use the same format for all the parameters
178+
app.dir.contents: '...'
179+
app.contents-dir: '...'
180+
156181
Semantic Configuration: Don't Do It
157182
-----------------------------------
158183

bundles.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ of the most common elements of a bundle:
153153
Houses configuration, including routing configuration (e.g. ``routing.yml``).
154154

155155
``Resources/views/``
156-
Holds templates organized by controller name (e.g. ``Hello/index.html.twig``).
156+
Holds templates organized by controller name (e.g. ``Random/index.html.twig``).
157157

158158
``Resources/public/``
159159
Contains web assets (images, stylesheets, etc) and is copied or symbolically
@@ -180,4 +180,4 @@ Learn more
180180

181181
bundles/*
182182

183-
_`third-party bundles`: http://knpbundles.com
183+
_`third-party bundles`: https://github.com/search?q=topic%3Asymfony-bundle&type=Repositories

bundles/installation.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ the bundle on the `Packagist.org`_ site.
2626

2727
.. tip::
2828

29-
Looking for bundles? Try searching at `KnpBundles.com`_: the unofficial
30-
archive of Symfony Bundles.
29+
Looking for bundles? Try searching for `symfony-bundle topic on GitHub`_.
3130

3231
2) Install the Bundle via Composer
3332
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -142,5 +141,5 @@ what to do next. Have fun!
142141
.. _their documentation: https://getcomposer.org/doc/00-intro.md
143142
.. _Packagist.org: https://packagist.org
144143
.. _FOSUserBundle: https://github.com/FriendsOfSymfony/FOSUserBundle
145-
.. _KnpBundles.com: http://knpbundles.com/
146144
.. _`composer require`: https://getcomposer.org/doc/03-cli.md#require
145+
.. _`symfony-bundle topic on GitHub`: https://github.com/search?q=topic%3Asymfony-bundle&type=Repositories

components/dependency_injection/workflow.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
Container Building Workflow
55
===========================
66

7-
In the preceding pages of this section, there has been little to say about
8-
where the various files and classes should be located. This is because this
9-
depends on the application, library or framework in which you want to use
10-
the container. Looking at how the container is configured and built in the
11-
Symfony full-stack Framework will help you see how this all fits together,
7+
The location of the files and classes related to the Dependency Injection
8+
component depends on the application, library or framework in which you want
9+
to use the container. Looking at how the container is configured and built
10+
in the Symfony full-stack Framework will help you see how this all fits together,
1211
whether you are using the full-stack framework or looking to use the service
1312
container in another application.
1413

components/dom_crawler.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ This allows you to use jQuery-like selectors to traverse::
7979

8080
$crawler = $crawler->filter('body > p');
8181

82-
Anonymous function can be used to filter with more complex criteria::
82+
An anonymous function can be used to filter with more complex criteria::
8383

8484
use Symfony\Component\DomCrawler\Crawler;
8585
// ...

components/form.rst

Lines changed: 75 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -463,19 +463,29 @@ builder:
463463
464464
.. code-block:: php-symfony
465465
466+
// src/Acme/TaskBundle/Controller/DefaultController.php
467+
namespace Acme\TaskBundle\Controller;
468+
469+
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
466470
use Symfony\Component\Form\Extension\Core\Type\TextType;
467471
use Symfony\Component\Form\Extension\Core\Type\DateType;
468472
469-
// ...
473+
class DefaultController extends Controller
474+
{
475+
public function newAction(Request $request)
476+
{
477+
$defaults = array(
478+
'dueDate' => new \DateTime('tomorrow'),
479+
);
470480
471-
$defaults = array(
472-
'dueDate' => new \DateTime('tomorrow'),
473-
);
481+
$form = $this->createFormBuilder($defaults)
482+
->add('task', TextType::class)
483+
->add('dueDate', DateType::class)
484+
->getForm();
474485

475-
$form = $this->createFormBuilder($defaults)
476-
->add('task', TextType::class)
477-
->add('dueDate', DateType::class)
478-
->getForm();
486+
// ...
487+
}
488+
}
479489

480490
.. tip::
481491

@@ -539,18 +549,23 @@ by ``handleRequest()`` to determine whether a form has been submitted):
539549
540550
.. code-block:: php-symfony
541551
542-
use Symfony\Component\Form\Extension\Core\Type\FormType;
552+
// src/Acme/TaskBundle/Controller/DefaultController.php
553+
namespace Acme\TaskBundle\Controller;
543554
544-
// ...
555+
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
556+
use Symfony\Component\Form\Extension\Core\Type\FormType;
545557
546-
public function searchAction()
558+
class DefaultController extends Controller
547559
{
548-
$formBuilder = $this->createFormBuilder(null, array(
549-
'action' => '/search',
550-
'method' => 'GET',
551-
));
560+
public function searchAction()
561+
{
562+
$formBuilder = $this->createFormBuilder(null, array(
563+
'action' => '/search',
564+
'method' => 'GET',
565+
));
552566
553-
// ...
567+
// ...
568+
}
554569
}
555570
556571
.. _component-form-intro-handling-submission:
@@ -567,8 +582,8 @@ method:
567582
568583
use Symfony\Component\HttpFoundation\Request;
569584
use Symfony\Component\HttpFoundation\RedirectResponse;
570-
use Symfony\Component\Form\Extension\Core\Type\TextType;
571585
use Symfony\Component\Form\Extension\Core\Type\DateType;
586+
use Symfony\Component\Form\Extension\Core\Type\TextType;
572587
573588
// ...
574589
@@ -596,29 +611,34 @@ method:
596611
597612
.. code-block:: php-symfony
598613
599-
use Symfony\Component\Form\Extension\Core\Type\TextType;
600-
use Symfony\Component\Form\Extension\Core\Type\DateType;
614+
// src/Acme/TaskBundle/Controller/DefaultController.php
615+
namespace Acme\TaskBundle\Controller;
601616
602-
// ...
617+
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
618+
use Symfony\Component\Form\Extension\Core\Type\DateType;
619+
use Symfony\Component\Form\Extension\Core\Type\TextType;
603620
604-
public function newAction(Request $request)
621+
class DefaultController extends Controller
605622
{
606-
$form = $this->createFormBuilder()
607-
->add('task', TextType::class)
608-
->add('dueDate', DateType::class)
609-
->getForm();
623+
public function newAction(Request $request)
624+
{
625+
$form = $this->createFormBuilder()
626+
->add('task', TextType::class)
627+
->add('dueDate', DateType::class)
628+
->getForm();
610629

611-
$form->handleRequest($request);
630+
$form->handleRequest($request);
612631

613-
if ($form->isSubmitted() && $form->isValid()) {
614-
$data = $form->getData();
632+
if ($form->isSubmitted() && $form->isValid()) {
633+
$data = $form->getData();
615634

616-
// ... perform some action, such as saving the data to the database
635+
// ... perform some action, such as saving the data to the database
617636

618-
return $this->redirectToRoute('task_success');
619-
}
637+
return $this->redirectToRoute('task_success');
638+
}
620639

621-
// ...
640+
// ...
641+
}
622642
}
623643

624644
This defines a common form "workflow", which contains 3 different possibilities:
@@ -667,22 +687,33 @@ option when building each field:
667687
668688
.. code-block:: php-symfony
669689
690+
// src/Acme/TaskBundle/Controller/DefaultController.php
691+
namespace Acme\TaskBundle\Controller;
692+
693+
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
670694
use Symfony\Component\Validator\Constraints\NotBlank;
671695
use Symfony\Component\Validator\Constraints\Type;
672-
use Symfony\Component\Form\Extension\Core\Type\TextType;
673696
use Symfony\Component\Form\Extension\Core\Type\DateType;
697+
use Symfony\Component\Form\Extension\Core\Type\TextType;
674698
675-
$form = $this->createFormBuilder()
676-
->add('task', TextType::class, array(
677-
'constraints' => new NotBlank(),
678-
))
679-
->add('dueDate', DateType::class, array(
680-
'constraints' => array(
681-
new NotBlank(),
682-
new Type(\DateTime::class),
683-
)
684-
))
685-
->getForm();
699+
class DefaultController extends Controller
700+
{
701+
public function newAction(Request $request)
702+
{
703+
$form = $this->createFormBuilder()
704+
->add('task', TextType::class, array(
705+
'constraints' => new NotBlank(),
706+
))
707+
->add('dueDate', DateType::class, array(
708+
'constraints' => array(
709+
new NotBlank(),
710+
new Type(\DateTime::class),
711+
)
712+
))
713+
->getForm();
714+
// ...
715+
}
716+
}
686717

687718
When the form is bound, these validation constraints will be applied automatically
688719
and the errors will display next to the fields on error.

0 commit comments

Comments
 (0)