Skip to content

Commit de04468

Browse files
committed
Merge branch '2.8' into 3.2
2 parents 53e4ee9 + 05c632e commit de04468

33 files changed

+220
-95
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
@@ -154,7 +154,7 @@ of the most common elements of a bundle:
154154
Houses configuration, including routing configuration (e.g. ``routing.yml``).
155155

156156
``Resources/views/``
157-
Holds templates organized by controller name (e.g. ``Hello/index.html.twig``).
157+
Holds templates organized by controller name (e.g. ``Random/index.html.twig``).
158158

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

182182
bundles/*
183183

184-
_`third-party bundles`: http://knpbundles.com
184+
_`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
@@ -81,7 +81,7 @@ This allows you to use jQuery-like selectors to traverse::
8181

8282
$crawler = $crawler->filter('body > p');
8383

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

8686
use Symfony\Component\DomCrawler\Crawler;
8787
// ...

components/form.rst

Lines changed: 75 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -460,19 +460,29 @@ builder:
460460
461461
.. code-block:: php-symfony
462462
463+
// src/Acme/TaskBundle/Controller/DefaultController.php
464+
namespace Acme\TaskBundle\Controller;
465+
466+
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
463467
use Symfony\Component\Form\Extension\Core\Type\TextType;
464468
use Symfony\Component\Form\Extension\Core\Type\DateType;
465469
466-
// ...
470+
class DefaultController extends Controller
471+
{
472+
public function newAction(Request $request)
473+
{
474+
$defaults = array(
475+
'dueDate' => new \DateTime('tomorrow'),
476+
);
467477
468-
$defaults = array(
469-
'dueDate' => new \DateTime('tomorrow'),
470-
);
478+
$form = $this->createFormBuilder($defaults)
479+
->add('task', TextType::class)
480+
->add('dueDate', DateType::class)
481+
->getForm();
471482

472-
$form = $this->createFormBuilder($defaults)
473-
->add('task', TextType::class)
474-
->add('dueDate', DateType::class)
475-
->getForm();
483+
// ...
484+
}
485+
}
476486

477487
.. tip::
478488

@@ -532,18 +542,23 @@ by ``handleRequest()`` to determine whether a form has been submitted):
532542
533543
.. code-block:: php-symfony
534544
535-
use Symfony\Component\Form\Extension\Core\Type\FormType;
545+
// src/Acme/TaskBundle/Controller/DefaultController.php
546+
namespace Acme\TaskBundle\Controller;
536547
537-
// ...
548+
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
549+
use Symfony\Component\Form\Extension\Core\Type\FormType;
538550
539-
public function searchAction()
551+
class DefaultController extends Controller
540552
{
541-
$formBuilder = $this->createFormBuilder(null, array(
542-
'action' => '/search',
543-
'method' => 'GET',
544-
));
553+
public function searchAction()
554+
{
555+
$formBuilder = $this->createFormBuilder(null, array(
556+
'action' => '/search',
557+
'method' => 'GET',
558+
));
545559
546-
// ...
560+
// ...
561+
}
547562
}
548563
549564
.. _component-form-intro-handling-submission:
@@ -560,8 +575,8 @@ method:
560575
561576
use Symfony\Component\HttpFoundation\Request;
562577
use Symfony\Component\HttpFoundation\RedirectResponse;
563-
use Symfony\Component\Form\Extension\Core\Type\TextType;
564578
use Symfony\Component\Form\Extension\Core\Type\DateType;
579+
use Symfony\Component\Form\Extension\Core\Type\TextType;
565580
566581
// ...
567582
@@ -589,29 +604,34 @@ method:
589604
590605
.. code-block:: php-symfony
591606
592-
use Symfony\Component\Form\Extension\Core\Type\TextType;
593-
use Symfony\Component\Form\Extension\Core\Type\DateType;
607+
// src/Acme/TaskBundle/Controller/DefaultController.php
608+
namespace Acme\TaskBundle\Controller;
594609
595-
// ...
610+
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
611+
use Symfony\Component\Form\Extension\Core\Type\DateType;
612+
use Symfony\Component\Form\Extension\Core\Type\TextType;
596613
597-
public function newAction(Request $request)
614+
class DefaultController extends Controller
598615
{
599-
$form = $this->createFormBuilder()
600-
->add('task', TextType::class)
601-
->add('dueDate', DateType::class)
602-
->getForm();
616+
public function newAction(Request $request)
617+
{
618+
$form = $this->createFormBuilder()
619+
->add('task', TextType::class)
620+
->add('dueDate', DateType::class)
621+
->getForm();
603622

604-
$form->handleRequest($request);
623+
$form->handleRequest($request);
605624

606-
if ($form->isSubmitted() && $form->isValid()) {
607-
$data = $form->getData();
625+
if ($form->isSubmitted() && $form->isValid()) {
626+
$data = $form->getData();
608627

609-
// ... perform some action, such as saving the data to the database
628+
// ... perform some action, such as saving the data to the database
610629

611-
return $this->redirectToRoute('task_success');
612-
}
630+
return $this->redirectToRoute('task_success');
631+
}
613632

614-
// ...
633+
// ...
634+
}
615635
}
616636

617637
This defines a common form "workflow", which contains 3 different possibilities:
@@ -660,22 +680,33 @@ option when building each field:
660680
661681
.. code-block:: php-symfony
662682
683+
// src/Acme/TaskBundle/Controller/DefaultController.php
684+
namespace Acme\TaskBundle\Controller;
685+
686+
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
663687
use Symfony\Component\Validator\Constraints\NotBlank;
664688
use Symfony\Component\Validator\Constraints\Type;
665-
use Symfony\Component\Form\Extension\Core\Type\TextType;
666689
use Symfony\Component\Form\Extension\Core\Type\DateType;
690+
use Symfony\Component\Form\Extension\Core\Type\TextType;
667691
668-
$form = $this->createFormBuilder()
669-
->add('task', TextType::class, array(
670-
'constraints' => new NotBlank(),
671-
))
672-
->add('dueDate', DateType::class, array(
673-
'constraints' => array(
674-
new NotBlank(),
675-
new Type(\DateTime::class),
676-
)
677-
))
678-
->getForm();
692+
class DefaultController extends Controller
693+
{
694+
public function newAction(Request $request)
695+
{
696+
$form = $this->createFormBuilder()
697+
->add('task', TextType::class, array(
698+
'constraints' => new NotBlank(),
699+
))
700+
->add('dueDate', DateType::class, array(
701+
'constraints' => array(
702+
new NotBlank(),
703+
new Type(\DateTime::class),
704+
)
705+
))
706+
->getForm();
707+
// ...
708+
}
709+
}
679710

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

0 commit comments

Comments
 (0)