Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[book] Avoid scrollbars in code examples #2749

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 30, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion book/controller.rst
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,10 @@ For example, imagine you're processing a form submit::
if ($form->isValid()) {
// do some sort of processing

$this->get('session')->getFlashBag()->add('notice', 'Your changes were saved!');
$this->get('session')->getFlashBag()->add(
'notice',
'Your changes were saved!'
);

return $this->redirect($this->generateUrl(...));
}
Expand Down
26 changes: 19 additions & 7 deletions book/doctrine.rst
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,9 @@ just a simple PHP class.

.. code-block:: bash

$ php app/console doctrine:generate:entity --entity="AcmeStoreBundle:Product" --fields="name:string(255) price:float description:text"
$ php app/console doctrine:generate:entity \
--entity="AcmeStoreBundle:Product" \
--fields="name:string(255) price:float description:text"

.. index::
single: Doctrine; Adding mapping metadata
Expand Down Expand Up @@ -696,7 +698,10 @@ a controller, do the following::

$em = $this->getDoctrine()->getManager();
$query = $em->createQuery(
'SELECT p FROM AcmeStoreBundle:Product p WHERE p.price > :price ORDER BY p.price ASC'
'SELECT p
FROM AcmeStoreBundle:Product p
WHERE p.price > :price
ORDER BY p.price ASC'
)->setParameter('price', '19.99');

$products = $query->getResult();
Expand Down Expand Up @@ -858,7 +863,9 @@ ordered alphabetically.
public function findAllOrderedByName()
{
return $this->getEntityManager()
->createQuery('SELECT p FROM AcmeStoreBundle:Product p ORDER BY p.name ASC')
->createQuery(
'SELECT p FROM AcmeStoreBundle:Product p ORDER BY p.name ASC'
)
->getResult();
}
}
Expand Down Expand Up @@ -892,7 +899,8 @@ you can let Doctrine create the class for you.

.. code-block:: bash

$ php app/console doctrine:generate:entity --entity="AcmeStoreBundle:Category" --fields="name:string(255)"
$ php app/console doctrine:generate:entity --entity="AcmeStoreBundle:Category" \
--fields="name:string(255)"

This task generates the ``Category`` entity for you, with an ``id`` field,
a ``name`` field and the associated getter and setter functions.
Expand Down Expand Up @@ -937,7 +945,7 @@ To relate the ``Category`` and ``Product`` entities, start by creating a
products:
targetEntity: Product
mappedBy: category
# don't forget to init the collection in entity __construct() method
# don't forget to init the collection in the __construct() method of the entity

.. code-block:: xml

Expand All @@ -954,7 +962,10 @@ To relate the ``Category`` and ``Product`` entities, start by creating a
mapped-by="category"
/>

<!-- don't forget to init the collection in entity __construct() method -->
<!--
don't forget to init the collection in
the __construct() method of the entity
-->
</entity>
</doctrine-mapping>

Expand Down Expand Up @@ -1325,7 +1336,8 @@ the current date, only when the entity is first persisted (i.e. inserted):
<entity name="Acme\StoreBundle\Entity\Product">
<!-- ... -->
<lifecycle-callbacks>
<lifecycle-callback type="prePersist" method="setCreatedValue" />
<lifecycle-callback type="prePersist"
method="setCreatedValue" />
</lifecycle-callbacks>
</entity>
</doctrine-mapping>
Expand Down
26 changes: 18 additions & 8 deletions book/forms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,10 @@ object.
$metadata->addPropertyConstraint('task', new NotBlank());

$metadata->addPropertyConstraint('dueDate', new NotBlank());
$metadata->addPropertyConstraint('dueDate', new Type('\DateTime'));
$metadata->addPropertyConstraint(
'dueDate',
new Type('\DateTime')
);
}
}

Expand Down Expand Up @@ -424,7 +427,10 @@ to an array callback, or a ``Closure``::
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'validation_groups' => array('Acme\\AcmeBundle\\Entity\\Client', 'determineValidationGroups'),
'validation_groups' => array(
'Acme\AcmeBundle\Entity\Client',
'determineValidationGroups',
),
));
}

Expand Down Expand Up @@ -903,7 +909,8 @@ easy to use in your application.
.. code-block:: xml

<!-- src/Acme/TaskBundle/Resources/config/services.xml -->
<service id="acme_demo.form.type.task" class="Acme\TaskBundle\Form\Type\TaskType">
<service id="acme_demo.form.type.task"
class="Acme\TaskBundle\Form\Type\TaskType">
<tag name="form.type" alias="task" />
</service>

Expand All @@ -913,7 +920,10 @@ easy to use in your application.
use Symfony\Component\DependencyInjection\Definition;

$container
->register('acme_demo.form.type.task', 'Acme\TaskBundle\Form\Type\TaskType')
->register(
'acme_demo.form.type.task',
'Acme\TaskBundle\Form\Type\TaskType'
)
->addTag('form.type', array(
'alias' => 'task',
))
Expand Down Expand Up @@ -1286,13 +1296,13 @@ rendered (e.g. ``label``, ``widget``, ``errors``, etc). By default, there
are 4 possible *parts* of a form that can be rendered:

+-------------+--------------------------+---------------------------------------------------------+
| ``label`` | (e.g. ``form_label``) | renders the field's label |
| ``label`` | (e.g. ``form_label``) | renders the field's label |
+-------------+--------------------------+---------------------------------------------------------+
| ``widget`` | (e.g. ``form_widget``) | renders the field's HTML representation |
| ``widget`` | (e.g. ``form_widget``) | renders the field's HTML representation |
+-------------+--------------------------+---------------------------------------------------------+
| ``errors`` | (e.g. ``form_errors``) | renders the field's errors |
| ``errors`` | (e.g. ``form_errors``) | renders the field's errors |
+-------------+--------------------------+---------------------------------------------------------+
| ``row`` | (e.g. ``form_row``) | renders the field's entire row (label, widget & errors) |
| ``row`` | (e.g. ``form_row``) | renders the field's entire row (label, widget & errors) |
+-------------+--------------------------+---------------------------------------------------------+

.. note::
Expand Down
3 changes: 2 additions & 1 deletion book/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ Distribution:

.. code-block:: bash

php composer.phar create-project symfony/framework-standard-edition /path/to/webroot/Symfony 2.2.0
$ php composer.phar create-project \
symfony/framework-standard-edition /path/to/webroot/Symfony 2.2.0

.. tip::

Expand Down
45 changes: 35 additions & 10 deletions book/internals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,11 @@ and set a new ``Exception`` object, or do nothing::
response won't work. If you want to overwrite the status code (which you
should not without a good reason), set the ``X-Status-Code`` header::

return new Response('Error', 404 /* ignored */, array('X-Status-Code' => 200));
return new Response(
'Error',
404 // ignored,
array('X-Status-Code' => 200)
);

.. index::
single: Event Dispatcher
Expand Down Expand Up @@ -610,11 +614,19 @@ If you enable the web profiler, you also need to mount the profiler routes:

.. code-block:: xml

<import resource="@WebProfilerBundle/Resources/config/routing/profiler.xml" prefix="/_profiler" />
<import
resource="@WebProfilerBundle/Resources/config/routing/profiler.xml"
prefix="/_profiler"
/>

.. code-block:: php

$collection->addCollection($loader->import("@WebProfilerBundle/Resources/config/routing/profiler.xml"), '/_profiler');
$collection->addCollection(
$loader->import(
"@WebProfilerBundle/Resources/config/routing/profiler.xml"
),
'/_profiler'
);

As the profiler adds some overhead, you might want to enable it only under
certain circumstances in the production environment. The ``only-exceptions``
Expand All @@ -626,7 +638,8 @@ portion of the website? You can use a request matcher:

.. code-block:: yaml

# enables the profiler only for request coming for the 192.168.0.0 network
# enables the profiler only for request coming
# for the 192.168.0.0 network
framework:
profiler:
matcher: { ip: 192.168.0.0/24 }
Expand All @@ -641,14 +654,18 @@ portion of the website? You can use a request matcher:
profiler:
matcher: { ip: 192.168.0.0/24, path: "^/admin/" }

# use a custom matcher instance defined in the "custom_matcher" service
# use a custom matcher instance defined in
# the "custom_matcher" service
framework:
profiler:
matcher: { service: custom_matcher }

.. code-block:: xml

<!-- enables the profiler only for request coming for the 192.168.0.0 network -->
<!--
enables the profiler only for request coming
for the 192.168.0.0 network
-->
<framework:config>
<framework:profiler>
<framework:matcher ip="192.168.0.0/24" />
Expand All @@ -669,7 +686,10 @@ portion of the website? You can use a request matcher:
</framework:profiler>
</framework:config>

<!-- use a custom matcher instance defined in the "custom_matcher" service -->
<!--
use a custom matcher instance defined in
the "custom_matcher" service
-->
<framework:config>
<framework:profiler>
<framework:matcher service="custom_matcher" />
Expand All @@ -678,7 +698,8 @@ portion of the website? You can use a request matcher:

.. code-block:: php

// enables the profiler only for request coming for the 192.168.0.0 network
// enables the profiler only for request coming
// for the 192.168.0.0 network
$container->loadFromExtension('framework', array(
'profiler' => array(
'matcher' => array('ip' => '192.168.0.0/24'),
Expand All @@ -695,11 +716,15 @@ portion of the website? You can use a request matcher:
// combine rules
$container->loadFromExtension('framework', array(
'profiler' => array(
'matcher' => array('ip' => '192.168.0.0/24', 'path' => '^/admin/'),
'matcher' => array(
'ip' => '192.168.0.0/24',
'path' => '^/admin/',
),
),
));

# use a custom matcher instance defined in the "custom_matcher" service
// use a custom matcher instance defined in
// the "custom_matcher" service
$container->loadFromExtension('framework', array(
'profiler' => array(
'matcher' => array('service' => 'custom_matcher'),
Expand Down
21 changes: 15 additions & 6 deletions book/page_creation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,11 @@ an entry when you generated the ``AcmeHelloBundle``:

<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
xsi:schemaLocation="http://symfony.com/schema/routing
http://symfony.com/schema/routing/routing-1.0.xsd">

<import resource="@AcmeHelloBundle/Resources/config/routing.xml" prefix="/" />
<import resource="@AcmeHelloBundle/Resources/config/routing.xml"
prefix="/" />
</routes>

.. code-block:: php
Expand Down Expand Up @@ -157,7 +159,8 @@ the new route that defines the URL of the page that you're about to create:

<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
xsi:schemaLocation="http://symfony.com/schema/routing
http://symfony.com/schema/routing/routing-1.0.xsd">

<route id="hello" path="/hello/{name}">
<default key="_controller">AcmeHelloBundle:Hello:index</default>
Expand Down Expand Up @@ -771,7 +774,9 @@ format you prefer:

$container->loadFromExtension('framework', array(
'secret' => '%secret%',
'router' => array('resource' => '%kernel.root_dir%/config/routing.php'),
'router' => array(
'resource' => '%kernel.root_dir%/config/routing.php',
),
// ...
),
));
Expand Down Expand Up @@ -940,7 +945,9 @@ the configuration file for the ``dev`` environment.
</imports>

<framework:config>
<framework:router resource="%kernel.root_dir%/config/routing_dev.xml" />
<framework:router
resource="%kernel.root_dir%/config/routing_dev.xml"
/>
<framework:profiler only-exceptions="false" />
</framework:config>

Expand All @@ -952,7 +959,9 @@ the configuration file for the ``dev`` environment.
$loader->import('config.php');

$container->loadFromExtension('framework', array(
'router' => array('resource' => '%kernel.root_dir%/config/routing_dev.php'),
'router' => array(
'resource' => '%kernel.root_dir%/config/routing_dev.php',
),
'profiler' => array('only-exceptions' => false),
));

Expand Down
3 changes: 2 additions & 1 deletion book/performance.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ as comments in this file::
$loader = require_once __DIR__.'/../app/bootstrap.php.cache';

// Use APC for autoloading to improve performance
// Change 'sf2' by the prefix you want in order to prevent key conflict with another application
// Change 'sf2' by the prefix you want in order
// to prevent key conflict with another application
/*
$loader = new ApcClassLoader('sf2', $loader);
$loader->register(true);
Expand Down
40 changes: 32 additions & 8 deletions book/propel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -304,22 +304,46 @@ Start by adding the ``category`` definition in your ``schema.xml``:

.. code-block:: xml

<database name="default" namespace="Acme\StoreBundle\Model" defaultIdMethod="native">
<database name="default"
namespace="Acme\StoreBundle\Model"
defaultIdMethod="native">
<table name="product">
<column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" />
<column name="name" type="varchar" primaryString="true" size="100" />
<column name="price" type="decimal" />
<column name="description" type="longvarchar" />
<column name="id"
type="integer"
required="true"
primaryKey="true"
autoIncrement="true" />

<column name="name"
type="varchar"
primaryString="true"
size="100" />

<column name="price"
type="decimal" />

<column name="description"
type="longvarchar" />

<column name="category_id"
type="integer" />

<column name="category_id" type="integer" />
<foreign-key foreignTable="category">
<reference local="category_id" foreign="id" />
</foreign-key>
</table>

<table name="category">
<column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" />
<column name="name" type="varchar" primaryString="true" size="100" />
<column name="id"
type="integer"
required="true"
primaryKey="true"
autoIncrement="true" />

<column name="name"
type="varchar"
primaryString="true"
size="100" />
</table>
</database>

Expand Down
Loading