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 0683a4b

Browse filesBrowse files
committed
Merge branch '2.0'
Conflicts: book/controller.rst book/doctrine.rst book/routing.rst book/templating.rst components/class_loader.rst components/routing.rst cookbook/configuration/pdo_session_storage.rst cookbook/doctrine/custom_dql_functions.rst cookbook/symfony1.rst cookbook/validation/custom_constraint.rst
2 parents ded03e3 + 186115d commit 0683a4b
Copy full SHA for 0683a4b

File tree

Expand file treeCollapse file tree

76 files changed

+438
-421
lines changed
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

76 files changed

+438
-421
lines changed

‎book/controller.rst

Copy file name to clipboardExpand all lines: book/controller.rst
+7-6Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ the following guidelines in mind while you develop.
276276

277277
public function indexAction($last_name, $color, $first_name)
278278
{
279-
// ..
279+
// ...
280280
}
281281

282282
* **Each required controller argument must match up with a routing parameter**
@@ -286,15 +286,15 @@ the following guidelines in mind while you develop.
286286

287287
public function indexAction($first_name, $last_name, $color, $foo)
288288
{
289-
// ..
289+
// ...
290290
}
291291

292292
Making the argument optional, however, is perfectly ok. The following
293293
example would not throw an exception::
294294

295295
public function indexAction($first_name, $last_name, $color, $foo = 'bar')
296296
{
297-
// ..
297+
// ...
298298
}
299299

300300
* **Not all routing parameters need to be arguments on your controller**
@@ -304,7 +304,7 @@ the following guidelines in mind while you develop.
304304

305305
public function indexAction($first_name, $color)
306306
{
307-
// ..
307+
// ...
308308
}
309309

310310
.. tip::
@@ -448,7 +448,7 @@ object that's returned from that controller::
448448
'color' => 'green'
449449
));
450450

451-
// further modify the response or return it directly
451+
// ... further modify the response or return it directly
452452

453453
return $response;
454454
}
@@ -570,7 +570,8 @@ If you're extending the base controller class, do the following::
570570

571571
public function indexAction()
572572
{
573-
$product = // retrieve the object from database
573+
// retrieve the object from database
574+
$product = ...;
574575
if (!$product) {
575576
throw $this->createNotFoundException('The product does not exist');
576577
}

‎book/doctrine.rst

Copy file name to clipboardExpand all lines: book/doctrine.rst
+17-12Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ information. By convention, this information is usually configured in an
4848

4949
.. code-block:: yaml
5050
51-
# app/config/parameters.yml
52-
parameters:
53-
database_driver: pdo_mysql
54-
database_host: localhost
55-
database_name: test_project
56-
database_user: root
57-
database_password: password
51+
; app/config/parameters.ini
52+
[parameters]
53+
database_driver = pdo_mysql
54+
database_host = localhost
55+
database_name = test_project
56+
database_user = root
57+
database_password = password
5858
5959
.. note::
6060

@@ -64,6 +64,7 @@ information. By convention, this information is usually configured in an
6464

6565
.. code-block:: yaml
6666
67+
# app/config/config.yml
6768
doctrine:
6869
dbal:
6970
driver: %database_driver%
@@ -366,9 +367,10 @@ of the bundle:
366367
:linenos:
367368
368369
// src/Acme/StoreBundle/Controller/DefaultController.php
370+
371+
// ...
369372
use Acme\StoreBundle\Entity\Product;
370373
use Symfony\Component\HttpFoundation\Response;
371-
// ...
372374
373375
public function createAction()
374376
{
@@ -444,7 +446,7 @@ on its ``id`` value::
444446
throw $this->createNotFoundException('No product found for id '.$id);
445447
}
446448

447-
// do something, like pass the $product object into a template
449+
// ... do something, like pass the $product object into a template
448450
}
449451

450452
When you query for a particular type of object, you always use what's known
@@ -605,7 +607,7 @@ for just one object, you can use the ``getSingleResult()`` method instead::
605607
returned (if you're querying on something that could feasibly return
606608
more than one result)::
607609
608-
$query = $em->createQuery('SELECT ....')
610+
$query = $em->createQuery('SELECT ...')
609611
->setMaxResults(1);
610612
611613
try {
@@ -710,6 +712,7 @@ To do this, add the name of the repository class to your mapping definition.
710712
.. code-block:: xml
711713
712714
<!-- src/Acme/StoreBundle/Resources/config/doctrine/Product.orm.xml -->
715+
713716
<!-- ... -->
714717
<doctrine-mapping>
715718
@@ -792,6 +795,7 @@ To relate the ``Category`` and ``Product`` entities, start by creating a
792795
.. code-block:: php-annotations
793796
794797
// src/Acme/StoreBundle/Entity/Category.php
798+
795799
// ...
796800
use Doctrine\Common\Collections\ArrayCollection;
797801
@@ -852,6 +856,7 @@ object, you'll want to add a ``$category`` property to the ``Product`` class:
852856
.. code-block:: php-annotations
853857
854858
// src/Acme/StoreBundle/Entity/Product.php
859+
855860
// ...
856861
857862
class Product
@@ -928,10 +933,10 @@ Saving Related Entities
928933
Now, let's see the code in action. Imagine you're inside a controller::
929934

930935
// ...
936+
931937
use Acme\StoreBundle\Entity\Category;
932938
use Acme\StoreBundle\Entity\Product;
933939
use Symfony\Component\HttpFoundation\Response;
934-
// ...
935940

936941
class DefaultController extends Controller
937942
{
@@ -1058,7 +1063,6 @@ can avoid the second query by issuing a join in the original query. Add the
10581063
following method to the ``ProductRepository`` class::
10591064

10601065
// src/Acme/StoreBundle/Repository/ProductRepository.php
1061-
10621066
public function findOneByIdJoinedToCategory($id)
10631067
{
10641068
$query = $this->getManager()
@@ -1162,6 +1166,7 @@ the current date, only when the entity is first persisted (i.e. inserted):
11621166
.. code-block:: xml
11631167
11641168
<!-- src/Acme/StoreBundle/Resources/config/doctrine/Product.orm.xml -->
1169+
11651170
<!-- ... -->
11661171
<doctrine-mapping>
11671172

‎book/forms.rst

Copy file name to clipboardExpand all lines: book/forms.rst
+3-18Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ helper functions:
147147
.. code-block:: html+jinja
148148

149149
{# src/Acme/TaskBundle/Resources/views/Default/new.html.twig #}
150-
151150
<form action="{{ path('task_new') }}" method="post" {{ form_enctype(form) }}>
152151
{{ form_widget(form) }}
153152

@@ -157,7 +156,6 @@ helper functions:
157156
.. code-block:: html+php
158157

159158
<!-- src/Acme/TaskBundle/Resources/views/Default/new.html.php -->
160-
161159
<form action="<?php echo $view['router']->generate('task_new') ?>" method="post" <?php echo $view['form']->enctype($form) ?> >
162160
<?php echo $view['form']->widget($form) ?>
163161

@@ -391,8 +389,7 @@ you'll need to specify which validation group(s) your form should use::
391389

392390
$form = $this->createFormBuilder($users, array(
393391
'validation_groups' => array('registration'),
394-
))->add(...)
395-
;
392+
))->add(...);
396393

397394
If you're creating :ref:`form classes<book-form-creating-form-classes>` (a
398395
good practice), then you'll need to add the following to the ``setDefaultOptions()``
@@ -607,7 +604,6 @@ of code. Of course, you'll usually need much more flexibility when rendering:
607604
.. code-block:: html+jinja
608605

609606
{# src/Acme/TaskBundle/Resources/views/Default/new.html.twig #}
610-
611607
<form action="{{ path('task_new') }}" method="post" {{ form_enctype(form) }}>
612608
{{ form_errors(form) }}
613609

@@ -621,8 +617,7 @@ of code. Of course, you'll usually need much more flexibility when rendering:
621617

622618
.. code-block:: html+php
623619

624-
<!-- // src/Acme/TaskBundle/Resources/views/Default/newAction.html.php -->
625-
620+
<!-- src/Acme/TaskBundle/Resources/views/Default/newAction.html.php -->
626621
<form action="<?php echo $view['router']->generate('task_new') ?>" method="post" <?php echo $view['form']->enctype($form) ?>>
627622
<?php echo $view['form']->errors($form) ?>
628623

@@ -835,7 +830,7 @@ form "type"). It can be used to quickly build a form object in the controller:
835830
836831
public function newAction()
837832
{
838-
$task = // ...
833+
$task = ...;
839834
$form = $this->createForm(new TaskType(), $task);
840835
841836
// ...
@@ -1107,7 +1102,6 @@ do this, create a new template file that will store the new markup:
11071102
.. code-block:: html+jinja
11081103

11091104
{# src/Acme/TaskBundle/Resources/views/Form/fields.html.twig #}
1110-
11111105
{% block field_row %}
11121106
{% spaceless %}
11131107
<div class="form_row">
@@ -1121,7 +1115,6 @@ do this, create a new template file that will store the new markup:
11211115
.. code-block:: html+php
11221116

11231117
<!-- src/Acme/TaskBundle/Resources/views/Form/field_row.html.php -->
1124-
11251118
<div class="form_row">
11261119
<?php echo $view['form']->label($form, $label) ?>
11271120
<?php echo $view['form']->errors($form) ?>
@@ -1138,7 +1131,6 @@ renders the form:
11381131
.. code-block:: html+jinja
11391132

11401133
{# src/Acme/TaskBundle/Resources/views/Default/new.html.twig #}
1141-
11421134
{% form_theme form 'AcmeTaskBundle:Form:fields.html.twig' %}
11431135

11441136
{% form_theme form 'AcmeTaskBundle:Form:fields.html.twig' 'AcmeTaskBundle:Form:fields2.html.twig' %}
@@ -1148,7 +1140,6 @@ renders the form:
11481140
.. code-block:: html+php
11491141

11501142
<!-- src/Acme/TaskBundle/Resources/views/Default/new.html.php -->
1151-
11521143
<?php $view['form']->setTheme($form, array('AcmeTaskBundle:Form')) ?>
11531144

11541145
<?php $view['form']->setTheme($form, array('AcmeTaskBundle:Form', 'AcmeTaskBundle:Form')) ?>
@@ -1287,7 +1278,6 @@ file:
12871278
.. code-block:: yaml
12881279
12891280
# app/config/config.yml
1290-
12911281
twig:
12921282
form:
12931283
resources:
@@ -1297,7 +1287,6 @@ file:
12971287
.. code-block:: xml
12981288
12991289
<!-- app/config/config.xml -->
1300-
13011290
<twig:config ...>
13021291
<twig:form>
13031292
<resource>AcmeTaskBundle:Form:fields.html.twig</resource>
@@ -1308,7 +1297,6 @@ file:
13081297
.. code-block:: php
13091298
13101299
// app/config/config.php
1311-
13121300
$container->loadFromExtension('twig', array(
13131301
'form' => array('resources' => array(
13141302
'AcmeTaskBundle:Form:fields.html.twig',
@@ -1365,7 +1353,6 @@ file:
13651353
.. code-block:: yaml
13661354
13671355
# app/config/config.yml
1368-
13691356
framework:
13701357
templating:
13711358
form:
@@ -1377,7 +1364,6 @@ file:
13771364
.. code-block:: xml
13781365
13791366
<!-- app/config/config.xml -->
1380-
13811367
<framework:config ...>
13821368
<framework:templating>
13831369
<framework:form>
@@ -1390,7 +1376,6 @@ file:
13901376
.. code-block:: php
13911377
13921378
// app/config/config.php
1393-
13941379
$container->loadFromExtension('framework', array(
13951380
'templating' => array('form' =>
13961381
array('resources' => array(

‎book/from_flat_php_to_symfony2.rst

Copy file name to clipboardExpand all lines: book/from_flat_php_to_symfony2.rst
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ persisted to the database. Writing in flat PHP is quick and dirty:
2727

2828
<?php
2929
// index.php
30-
3130
$link = mysql_connect('localhost', 'myuser', 'mypassword');
3231
mysql_select_db('blog_db', $link);
3332

3433
$result = mysql_query('SELECT id, title FROM post', $link);
3534
?>
3635

36+
<!doctype html>
3737
<html>
3838
<head>
3939
<title>List of Posts</title>
@@ -54,6 +54,7 @@ persisted to the database. Writing in flat PHP is quick and dirty:
5454

5555
<?php
5656
mysql_close($link);
57+
?>
5758

5859
That's quick to write, fast to execute, and, as your app grows, impossible
5960
to maintain. There are several problems that need to be addressed:
@@ -85,7 +86,6 @@ the code that prepares the HTML "presentation":
8586

8687
<?php
8788
// index.php
88-
8989
$link = mysql_connect('localhost', 'myuser', 'mypassword');
9090
mysql_select_db('blog_db', $link);
9191

@@ -106,6 +106,7 @@ is primarily an HTML file that uses a template-like PHP syntax:
106106

107107
.. code-block:: html+php
108108

109+
<!doctype html>
109110
<html>
110111
<head>
111112
<title>List of Posts</title>
@@ -146,7 +147,6 @@ of the application are isolated in a new file called ``model.php``:
146147

147148
<?php
148149
// model.php
149-
150150
function open_database_connection()
151151
{
152152
$link = mysql_connect('localhost', 'myuser', 'mypassword');
@@ -602,6 +602,7 @@ The layout is nearly identical:
602602
.. code-block:: html+php
603603

604604
<!-- app/Resources/views/layout.html.php -->
605+
<!doctype html>
605606
<html>
606607
<head>
607608
<title><?php echo $view['slots']->output('title', 'Default title') ?></title>
@@ -699,7 +700,6 @@ for example, the list template written in Twig:
699700
.. code-block:: html+jinja
700701

701702
{# src/Acme/BlogBundle/Resources/views/Blog/list.html.twig #}
702-
703703
{% extends "::layout.html.twig" %}
704704
{% block title %}List of Posts{% endblock %}
705705

@@ -708,7 +708,7 @@ for example, the list template written in Twig:
708708
<ul>
709709
{% for post in posts %}
710710
<li>
711-
<a href="{{ path('blog_show', { 'id': post.id }) }}">
711+
<a href="{{ path('blog_show', {'id': post.id}) }}">
712712
{{ post.title }}
713713
</a>
714714
</li>
@@ -721,7 +721,7 @@ The corresponding ``layout.html.twig`` template is also easier to write:
721721
.. code-block:: html+jinja
722722

723723
{# app/Resources/views/layout.html.twig #}
724-
724+
<!doctype html>
725725
<html>
726726
<head>
727727
<title>{% block title %}Default title{% endblock %}</title>

0 commit comments

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