Skip to content

Commit 0887fee

Browse files
committed
Merge pull request symfony#1798 from WouterJ/syntax_checks
[book] Fixed every inconsistention find in quick proofread
2 parents 500a101 + 2e2a73a commit 0887fee

18 files changed

+286
-318
lines changed

book/controller.rst

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,8 @@ Route Parameters as Controller Arguments
202202
You already know that the ``_controller`` parameter ``AcmeHelloBundle:Hello:index``
203203
refers to a ``HelloController::indexAction()`` method that lives inside the
204204
``AcmeHelloBundle`` bundle. What's more interesting is the arguments that are
205-
passed to that method:
205+
passed to that method::
206206

207-
.. code-block:: php
208-
209-
<?php
210207
// src/Acme/HelloBundle/Controller/HelloController.php
211208
namespace Acme\HelloBundle\Controller;
212209

@@ -344,9 +341,7 @@ access to any resource it might need. By extending this ``Controller`` class,
344341
you can take advantage of several helper methods.
345342

346343
Add the ``use`` statement atop the ``Controller`` class and then modify the
347-
``HelloController`` to extend it:
348-
349-
.. code-block:: php
344+
``HelloController`` to extend it::
350345

351346
// src/Acme/HelloBundle/Controller/HelloController.php
352347
namespace Acme\HelloBundle\Controller;
@@ -358,7 +353,7 @@ Add the ``use`` statement atop the ``Controller`` class and then modify the
358353
{
359354
public function indexAction($name)
360355
{
361-
return new Response('<html><body>Hello '.$name.'!</body></html>');
356+
return new Response('<html><body>Hello '.$name.'!</body></html>');
362357
}
363358
}
364359

@@ -375,13 +370,12 @@ itself.
375370

376371
Extending the base class is *optional* in Symfony; it contains useful
377372
shortcuts but nothing mandatory. You can also extend
378-
``Symfony\Component\DependencyInjection\ContainerAware``. The service
373+
:class:`Symfony\\Component\\DependencyInjection\\ContainerAware`. The service
379374
container object will then be accessible via the ``container`` property.
380375

381376
.. note::
382377

383-
You can also define your :doc:`Controllers as Services
384-
</cookbook/controller/service>`.
378+
You can also define your :doc:`Controllers as Services</cookbook/controller/service>`.
385379

386380
.. index::
387381
single: Controller; Common tasks
@@ -422,9 +416,7 @@ perform a 301 (permanent) redirect, modify the second argument::
422416
.. tip::
423417

424418
The ``redirect()`` method is simply a shortcut that creates a ``Response``
425-
object that specializes in redirecting the user. It's equivalent to:
426-
427-
.. code-block:: php
419+
object that specializes in redirecting the user. It's equivalent to::
428420

429421
use Symfony\Component\HttpFoundation\RedirectResponse;
430422

book/doctrine.rst

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ be.
1515

1616
Doctrine is totally decoupled from Symfony and using it is optional.
1717
This chapter is all about the Doctrine ORM, which aims to let you map
18-
objects to a relational database (such as *MySQL*, *PostgreSQL* or *Microsoft SQL*).
19-
If you prefer to use raw database queries, this is easy, and explained
20-
in the ":doc:`/cookbook/doctrine/dbal`" cookbook entry.
18+
objects to a relational database (such as *MySQL*, *PostgreSQL* or
19+
*Microsoft SQL*). If you prefer to use raw database queries, this is
20+
easy, and explained in the ":doc:`/cookbook/doctrine/dbal`" cookbook entry.
2121

2222
You can also persist data to `MongoDB`_ using Doctrine ODM library. For
2323
more information, read the ":doc:`/bundles/DoctrineMongoDBBundle/index`"
@@ -169,12 +169,6 @@ properties should be *mapped* to the database. This metadata can be specified
169169
in a number of different formats including YAML, XML or directly inside the
170170
``Product`` class via annotations:
171171

172-
.. note::
173-
174-
A bundle can accept only one metadata definition format. For example, it's
175-
not possible to mix YAML metadata definitions with annotated PHP entity
176-
class definitions.
177-
178172
.. configuration-block::
179173

180174
.. code-block:: php-annotations
@@ -251,6 +245,12 @@ in a number of different formats including YAML, XML or directly inside the
251245
</entity>
252246
</doctrine-mapping>
253247
248+
.. note::
249+
250+
A bundle can accept only one metadata definition format. For example, it's
251+
not possible to mix YAML metadata definitions with annotated PHP entity
252+
class definitions.
253+
254254
.. tip::
255255

256256
The table name is optional and if omitted, will be determined automatically
@@ -293,6 +293,7 @@ see the :ref:`book-doctrine-field-types` section.
293293
* @IgnoreAnnotation("fn")
294294
*/
295295
class Product
296+
// ...
296297

297298
Generating Getters and Setters
298299
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -316,10 +317,10 @@ doesn't replace your existing methods).
316317

317318
With the ``doctrine:generate:entities`` command you can:
318319

319-
* generate getters and setters,
320+
* generate getters and setters;
320321

321322
* generate repository classes configured with the
322-
``@ORM\Entity(repositoryClass="...")`` annotation,
323+
``@ORM\Entity(repositoryClass="...")`` annotation;
323324

324325
* generate the appropriate constructor for 1:n and n:m relations.
325326

@@ -420,11 +421,11 @@ of the bundle:
420421
Let's walk through this example:
421422

422423
* **lines 9-12** In this section, you instantiate and work with the ``$product``
423-
object like any other, normal PHP object;
424+
object like any other, normal PHP object.
424425

425426
* **line 14** This line fetches Doctrine's *entity manager* object, which is
426427
responsible for handling the process of persisting and fetching objects
427-
to and from the database;
428+
to and from the database.
428429

429430
* **line 15** The ``persist()`` method tells Doctrine to "manage" the ``$product``
430431
object. This does not actually cause a query to be made to the database (yet).
@@ -558,9 +559,9 @@ you have a route that maps a product id to an update action in a controller::
558559

559560
Updating an object involves just three steps:
560561

561-
1. fetching the object from Doctrine;
562-
2. modifying the object;
563-
3. calling ``flush()`` on the entity manager
562+
#. fetching the object from Doctrine;
563+
#. modifying the object;
564+
#. calling ``flush()`` on the entity manager
564565

565566
Notice that calling ``$em->persist($product)`` isn't necessary. Recall that
566567
this method simply tells Doctrine to manage or "watch" the ``$product`` object.
@@ -884,7 +885,6 @@ object, you'll want to add a ``$category`` property to the ``Product`` class:
884885
// src/Acme/StoreBundle/Entity/Product.php
885886
886887
// ...
887-
888888
class Product
889889
{
890890
// ...

book/forms.rst

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ Creating a Simple Form
2424
Suppose you're building a simple todo list application that will need to
2525
display "tasks". Because your users will need to edit and create tasks, you're
2626
going to need to build a form. But before you begin, first focus on the generic
27-
``Task`` class that represents and stores the data for a single task:
28-
29-
.. code-block:: php
27+
``Task`` class that represents and stores the data for a single task::
3028

3129
// src/Acme/TaskBundle/Entity/Task.php
3230
namespace Acme\TaskBundle\Entity;
@@ -742,9 +740,7 @@ Creating Form Classes
742740
As you've seen, a form can be created and used directly in a controller.
743741
However, a better practice is to build the form in a separate, standalone PHP
744742
class, which can then be reused anywhere in your application. Create a new class
745-
that will house the logic for building the task form:
746-
747-
.. code-block:: php
743+
that will house the logic for building the task form::
748744

749745
// src/Acme/TaskBundle/Form/Type/TaskType.php
750746
namespace Acme\TaskBundle\Form\Type;
@@ -768,9 +764,7 @@ that will house the logic for building the task form:
768764

769765
This new class contains all the directions needed to create the task form
770766
(note that the ``getName()`` method should return a unique identifier for this
771-
form "type"). It can be used to quickly build a form object in the controller:
772-
773-
.. code-block:: php
767+
form "type"). It can be used to quickly build a form object in the controller::
774768

775769
// src/Acme/TaskBundle/Controller/DefaultController.php
776770

@@ -1068,7 +1062,7 @@ The ``field_row`` form fragment is used when rendering most fields via the
10681062
fragment defined above, add the following to the top of the template that
10691063
renders the form:
10701064

1071-
.. configuration-block:: php
1065+
.. configuration-block::
10721066

10731067
.. code-block:: html+jinja
10741068

@@ -1373,7 +1367,7 @@ section.
13731367
The ``intention`` option is optional but greatly enhances the security of
13741368
the generated token by making it different for each form.
13751369

1376-
.. index:
1370+
.. index::
13771371
single: Forms; With no class
13781372

13791373
Using a Form without a Class
@@ -1413,10 +1407,10 @@ By default, a form actually assumes that you want to work with arrays of
14131407
data, instead of an object. There are exactly two ways that you can change
14141408
this behavior and tie the form to an object instead:
14151409

1416-
1. Pass an object when creating the form (as the first argument to ``createFormBuilder``
1410+
#. Pass an object when creating the form (as the first argument to ``createFormBuilder``
14171411
or the second argument to ``createForm``);
14181412

1419-
2. Declare the ``data_class`` option on your form.
1413+
#. Declare the ``data_class`` option on your form.
14201414

14211415
If you *don't* do either of these, then the form will return the data as
14221416
an array. In this example, since ``$defaultData`` is not an object (and
@@ -1426,9 +1420,7 @@ an array.
14261420
.. tip::
14271421

14281422
You can also access POST values (in this case "name") directly through
1429-
the request object, like so:
1430-
1431-
.. code-block:: php
1423+
the request object, like so::
14321424

14331425
$this->get('request')->request->get('name');
14341426

book/from_flat_php_to_symfony2.rst

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ persisted to the database. Writing in flat PHP is quick and dirty:
3333
$result = mysql_query('SELECT id, title FROM post', $link);
3434
?>
3535

36-
<!doctype html>
36+
<!DOCTYPE html>
3737
<html>
3838
<head>
3939
<title>List of Posts</title>
@@ -70,6 +70,7 @@ to maintain. There are several problems that need to be addressed:
7070
way to reuse any part of the application for other "pages" of the blog.
7171

7272
.. note::
73+
7374
Another problem not mentioned here is the fact that the database is
7475
tied to MySQL. Though not covered here, Symfony2 fully integrates `Doctrine`_,
7576
a library dedicated to database abstraction and mapping.
@@ -106,7 +107,7 @@ is primarily an HTML file that uses a template-like PHP syntax:
106107

107108
.. code-block:: html+php
108109

109-
<!doctype html>
110+
<!DOCTYPE html>
110111
<html>
111112
<head>
112113
<title>List of Posts</title>
@@ -211,6 +212,7 @@ that by creating a new ``layout.php`` file:
211212
.. code-block:: html+php
212213

213214
<!-- templates/layout.php -->
215+
<!DOCTYPE html>
214216
<html>
215217
<head>
216218
<title><?php echo $title ?></title>
@@ -366,9 +368,9 @@ on the requested URI:
366368

367369
// route the request internally
368370
$uri = $_SERVER['REQUEST_URI'];
369-
if ($uri == '/index.php') {
371+
if ('/index.php' == $uri) {
370372
list_action();
371-
} elseif ($uri == '/index.php/show' && isset($_GET['id'])) {
373+
} elseif ('/index.php/show' == $uri && isset($_GET['id'])) {
372374
show_action($_GET['id']);
373375
} else {
374376
header('Status: 404 Not Found');
@@ -466,9 +468,9 @@ the HTTP response being returned. Use them to improve the blog:
466468
$request = Request::createFromGlobals();
467469

468470
$uri = $request->getPathInfo();
469-
if ($uri == '/') {
471+
if ('/' == $uri) {
470472
$response = list_action();
471-
} elseif ($uri == '/show' && $request->query->has('id')) {
473+
} elseif ('/show' == $uri && $request->query->has('id')) {
472474
$response = show_action($request->query->get('id'));
473475
} else {
474476
$html = '<html><body><h1>Page Not Found</h1></body></html>';
@@ -537,11 +539,8 @@ from scratch, you could at least use Symfony's standalone `Routing`_ and
537539
`Templating`_ components, which already solve these problems.
538540

539541
Instead of re-solving common problems, you can let Symfony2 take care of
540-
them for you. Here's the same sample application, now built in Symfony2:
541-
542-
.. code-block:: html+php
542+
them for you. Here's the same sample application, now built in Symfony2::
543543

544-
<?php
545544
// src/Acme/BlogBundle/Controller/BlogController.php
546545
namespace Acme\BlogBundle\Controller;
547546

@@ -563,7 +562,8 @@ them for you. Here's the same sample application, now built in Symfony2:
563562
$post = $this->get('doctrine')
564563
->getEntityManager()
565564
->getRepository('AcmeBlogBundle:Post')
566-
->find($id);
565+
->find($id)
566+
;
567567
568568
if (!$post) {
569569
// cause the 404 page not found to be displayed
@@ -602,7 +602,7 @@ The layout is nearly identical:
602602
.. code-block:: html+php
603603

604604
<!-- app/Resources/views/layout.html.php -->
605-
<!doctype html>
605+
<!DOCTYPE html>
606606
<html>
607607
<head>
608608
<title><?php echo $view['slots']->output('title', 'Default title') ?></title>
@@ -635,11 +635,8 @@ A routing configuration map provides this information in a readable format:
635635
Now that Symfony2 is handling all the mundane tasks, the front controller
636636
is dead simple. And since it does so little, you'll never have to touch
637637
it once it's created (and if you use a Symfony2 distribution, you won't
638-
even need to create it!):
638+
even need to create it!)::
639639

640-
.. code-block:: html+php
641-
642-
<?php
643640
// web/app.php
644641
require_once __DIR__.'/../app/bootstrap.php';
645642
require_once __DIR__.'/../app/AppKernel.php';
@@ -667,18 +664,18 @@ migrating the blog from flat PHP to Symfony2 has improved life:
667664

668665
* Your application now has **clear and consistently organized code** (though
669666
Symfony doesn't force you into this). This promotes **reusability** and
670-
allows for new developers to be productive in your project more quickly.
667+
allows for new developers to be productive in your project more quickly;
671668

672669
* 100% of the code you write is for *your* application. You **don't need
673670
to develop or maintain low-level utilities** such as :ref:`autoloading<autoloading-introduction-sidebar>`,
674-
:doc:`routing</book/routing>`, or rendering :doc:`controllers</book/controller>`.
671+
:doc:`routing</book/routing>`, or rendering :doc:`controllers</book/controller>`;
675672

676673
* Symfony2 gives you **access to open source tools** such as Doctrine and the
677674
Templating, Security, Form, Validation and Translation components (to name
678-
a few).
675+
a few);
679676

680677
* The application now enjoys **fully-flexible URLs** thanks to the ``Routing``
681-
component.
678+
component;
682679

683680
* Symfony2's HTTP-centric architecture gives you access to powerful tools
684681
such as **HTTP caching** powered by **Symfony2's internal HTTP cache** or
@@ -701,6 +698,7 @@ for example, the list template written in Twig:
701698

702699
{# src/Acme/BlogBundle/Resources/views/Blog/list.html.twig #}
703700
{% extends "::layout.html.twig" %}
701+
704702
{% block title %}List of Posts{% endblock %}
705703

706704
{% block body %}
@@ -721,7 +719,7 @@ The corresponding ``layout.html.twig`` template is also easier to write:
721719
.. code-block:: html+jinja
722720

723721
{# app/Resources/views/layout.html.twig #}
724-
<!doctype html>
722+
<!DOCTYPE html>
725723
<html>
726724
<head>
727725
<title>{% block title %}Default title{% endblock %}</title>

0 commit comments

Comments
 (0)