Skip to content

Commit

Permalink
Merge branch '3.4' into 4.0
Browse files Browse the repository at this point in the history
* 3.4:
  Fixed indentation errors
  • Loading branch information
weaverryan committed Dec 19, 2017
2 parents 06e2096 + b998b9d commit 548360a
Show file tree
Hide file tree
Showing 21 changed files with 238 additions and 126 deletions.
118 changes: 115 additions & 3 deletions bundles.rst
Expand Up @@ -37,9 +37,121 @@ file::

.. tip::

In a default Symfony application that uses :doc:`Symfony Flex </setup/flex>`,
bundles are enabled/disabled automatically for you when installing/removing
them, so you don't need to look at or edit this ``bundles.php`` file.
In a default Symfony application that uses :doc:`Symfony Flex </setup/flex>`,
bundles are enabled/disabled automatically for you when installing/removing
them, so you don't need to look at or edit this ``bundles.php`` file.

Creating a Bundle
-----------------

The Symfony Standard Edition comes with a handy task that creates a fully-functional
bundle for you. Of course, creating a bundle by hand is pretty easy as well.

To show you how simple the bundle system is, create a new bundle called
AcmeTestBundle and enable it.

.. tip::

The ``Acme`` portion is just a dummy name that should be replaced by
some "vendor" name that represents you or your organization (e.g.
ABCTestBundle for some company named ``ABC``).

Start by creating a ``src/Acme/TestBundle/`` directory and adding a new file
called ``AcmeTestBundle.php``::

// src/Acme/TestBundle/AcmeTestBundle.php
namespace Acme\TestBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class AcmeTestBundle extends Bundle
{
}

.. tip::

The name AcmeTestBundle follows the standard
:ref:`Bundle naming conventions <bundles-naming-conventions>`. You could
also choose to shorten the name of the bundle to simply TestBundle by naming
this class TestBundle (and naming the file ``TestBundle.php``).

This empty class is the only piece you need to create the new bundle. Though
commonly empty, this class is powerful and can be used to customize the behavior
of the bundle.

Now that you've created the bundle, enable it via the ``AppKernel`` class::

// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...

// register your bundle
new Acme\TestBundle\AcmeTestBundle(),
);
// ...

return $bundles;
}

And while it doesn't do anything yet, AcmeTestBundle is now ready to be used.

And as easy as this is, Symfony also provides a command-line interface for
generating a basic bundle skeleton:

.. code-block:: terminal
$ php bin/console generate:bundle --namespace=Acme/TestBundle
The bundle skeleton generates a basic controller, template and routing
resource that can be customized. You'll learn more about Symfony's command-line
tools later.

.. tip::

Whenever creating a new bundle or using a third-party bundle, always make
sure the bundle has been enabled in ``registerBundles()``. When using
the ``generate:bundle`` command, this is done for you.

Bundle Directory Structure
--------------------------

The directory structure of a bundle is simple and flexible. By default, the
bundle system follows a set of conventions that help to keep code consistent
between all Symfony bundles. Take a look at AcmeDemoBundle, as it contains some
of the most common elements of a bundle:

``Controller/``
Contains the controllers of the bundle (e.g. ``RandomController.php``).

``DependencyInjection/``
Holds certain Dependency Injection Extension classes, which may import service
configuration, register compiler passes or more (this directory is not
necessary).

``Resources/config/``
Houses configuration, including routing configuration (e.g. ``routing.yml``).

``Resources/views/``
Holds templates organized by controller name (e.g. ``Random/index.html.twig``).

``Resources/public/``
Contains web assets (images, stylesheets, etc) and is copied or symbolically
linked into the project ``web/`` directory via the ``assets:install`` console
command.

``Tests/``
Holds all tests for the bundle.

A bundle can be as small or large as the feature it implements. It contains
only the files you need and nothing else.

As you move through the guides, you'll learn how to persist objects to a
database, create and validate forms, create translations for your application,
write tests and much more. Each of these has their own place and role within
the bundle.
>>>>>>> 3.4

Learn more
----------
Expand Down
4 changes: 2 additions & 2 deletions bundles/best_practices.rst
Expand Up @@ -163,8 +163,8 @@ the ``Tests/`` directory. Tests should follow the following principles:

.. note::

A test suite must not contain ``AllTests.php`` scripts, but must rely on the
existence of a ``phpunit.xml.dist`` file.
A test suite must not contain ``AllTests.php`` scripts, but must rely on the
existence of a ``phpunit.xml.dist`` file.

Installation
------------
Expand Down
4 changes: 2 additions & 2 deletions components/asset.rst
Expand Up @@ -5,8 +5,8 @@
The Asset Component
===================

The Asset component manages URL generation and versioning of web assets such
as CSS stylesheets, JavaScript files and image files.
The Asset component manages URL generation and versioning of web assets such
as CSS stylesheets, JavaScript files and image files.

In the past, it was common for web applications to hardcode URLs of web assets.
For example:
Expand Down
12 changes: 6 additions & 6 deletions components/event_dispatcher.rst
Expand Up @@ -402,14 +402,14 @@ the dispatcher to stop all propagation of the event to future listeners
inside a listener via the
:method:`Symfony\\Component\\EventDispatcher\\Event::stopPropagation` method::

use Acme\Store\Event\OrderPlacedEvent;
use Acme\Store\Event\OrderPlacedEvent;

public function onStoreOrder(OrderPlacedEvent $event)
{
// ...
public function onStoreOrder(OrderPlacedEvent $event)
{
// ...

$event->stopPropagation();
}
$event->stopPropagation();
}

Now, any listeners to ``order.placed`` that have not yet been called will
*not* be called.
Expand Down
4 changes: 2 additions & 2 deletions components/finder.rst
Expand Up @@ -5,8 +5,8 @@
The Finder Component
====================

The Finder component finds files and directories via an intuitive fluent
interface.
The Finder component finds files and directories via an intuitive fluent
interface.

Installation
------------
Expand Down
10 changes: 5 additions & 5 deletions components/process.rst
Expand Up @@ -328,12 +328,12 @@ Process Idle Timeout
In contrast to the timeout of the previous paragraph, the idle timeout only
considers the time since the last output was produced by the process::

use Symfony\Component\Process\Process;
use Symfony\Component\Process\Process;

$process = new Process('something-with-variable-runtime');
$process->setTimeout(3600);
$process->setIdleTimeout(60);
$process->run();
$process = new Process('something-with-variable-runtime');
$process->setTimeout(3600);
$process->setIdleTimeout(60);
$process->run();

In the case above, a process is considered timed out, when either the total runtime
exceeds 3600 seconds, or the process does not produce any output for 60 seconds.
Expand Down
48 changes: 24 additions & 24 deletions components/routing.rst
Expand Up @@ -5,8 +5,8 @@
The Routing Component
=====================

The Routing component maps an HTTP request to a set of configuration
variables.
The Routing component maps an HTTP request to a set of configuration
variables.

Installation
------------
Expand Down Expand Up @@ -100,28 +100,28 @@ A full route definition can contain up to seven parts:

Take the following route, which combines several of these ideas::

$route = new Route(
'/archive/{month}', // path
array('_controller' => 'showArchive'), // default values
array('month' => '[0-9]{4}-[0-9]{2}', 'subdomain' => 'www|m'), // requirements
array(), // options
'{subdomain}.example.com', // host
array(), // schemes
array() // methods
);

// ...

$parameters = $matcher->match('/archive/2012-01');
// array(
// '_controller' => 'showArchive',
// 'month' => '2012-01',
// 'subdomain' => 'www',
// '_route' => ...
// )

$parameters = $matcher->match('/archive/foo');
// throws ResourceNotFoundException
$route = new Route(
'/archive/{month}', // path
array('_controller' => 'showArchive'), // default values
array('month' => '[0-9]{4}-[0-9]{2}', 'subdomain' => 'www|m'), // requirements
array(), // options
'{subdomain}.example.com', // host
array(), // schemes
array() // methods
);

// ...

$parameters = $matcher->match('/archive/2012-01');
// array(
// '_controller' => 'showArchive',
// 'month' => '2012-01',
// 'subdomain' => 'www',
// '_route' => ...
// )

$parameters = $matcher->match('/archive/foo');
// throws ResourceNotFoundException

In this case, the route is matched by ``/archive/2012-01``, because the ``{month}``
wildcard matches the regular expression wildcard given. However, ``/archive/foo``
Expand Down
4 changes: 2 additions & 2 deletions components/serializer.rst
Expand Up @@ -5,8 +5,8 @@
The Serializer Component
========================

The Serializer component is meant to be used to turn objects into a
specific format (XML, JSON, YAML, ...) and the other way around.
The Serializer component is meant to be used to turn objects into a
specific format (XML, JSON, YAML, ...) and the other way around.

In order to do so, the Serializer component follows the following
simple schema.
Expand Down
8 changes: 4 additions & 4 deletions configuration/environments.rst
Expand Up @@ -100,8 +100,8 @@ your application in the configured environment.

.. note::

The given URLs assume that your web server is configured to use the ``public/``
directory of the application as its root. Read more in :doc:`Installing Symfony </setup>`.
The given URLs assume that your web server is configured to use the ``public/``
directory of the application as its root. Read more in :doc:`Installing Symfony </setup>`.

If you open the file you just visited (``public/index.php``), you'll see that
the environment variable is passed to the kernel::
Expand All @@ -119,8 +119,8 @@ always run the application in the dev environment, independent of the

.. note::

The ``test`` environment is used when writing functional tests and is
usually not accessed in the browser directly via a front controller.
The ``test`` environment is used when writing functional tests and is
usually not accessed in the browser directly via a front controller.

.. index::
single: Configuration; Debug mode
Expand Down
6 changes: 3 additions & 3 deletions contributing/code/patches.rst
Expand Up @@ -18,9 +18,9 @@ software:

.. caution::

Before Symfony 2.7, the minimal PHP version was 5.3.3. Before Symfony 3.0,
minimal version was 5.3.9. Please keep this in mind, if you are working on a
bug fix for earlier versions of Symfony.
Before Symfony 2.7, the minimal PHP version was 5.3.3. Before Symfony 3.0,
minimal version was 5.3.9. Please keep this in mind, if you are working on a
bug fix for earlier versions of Symfony.

Configure Git
~~~~~~~~~~~~~
Expand Down
4 changes: 2 additions & 2 deletions doctrine/registration_form.rst
Expand Up @@ -335,8 +335,8 @@ your database schema using this command:

.. code-block:: terminal
$ php bin/console doctrine:migrations:diff
$ php bin/console doctrine:migrations:migrate
$ php bin/console doctrine:migrations:diff
$ php bin/console doctrine:migrations:migrate
That's it! Head to ``/register`` to try things out!

Expand Down
25 changes: 13 additions & 12 deletions form/form_customization.rst
Expand Up @@ -760,14 +760,14 @@ field whose *id* is ``product_name`` (and name is ``product[name]``).

.. tip::

The ``product`` portion of the field is the form name, which may be set
manually or generated automatically based on your form type name (e.g.
``ProductType`` equates to ``product``). If you're not sure what your
form name is, just view the source of your generated form.
The ``product`` portion of the field is the form name, which may be set
manually or generated automatically based on your form type name (e.g.
``ProductType`` equates to ``product``). If you're not sure what your
form name is, just view the source of your generated form.

If you want to change the ``product`` or ``name`` portion of the block
name ``_product_name_widget`` you can set the ``block_name`` option in your
form type::
If you want to change the ``product`` or ``name`` portion of the block
name ``_product_name_widget`` you can set the ``block_name`` option in your
form type::

use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\TextType;
Expand All @@ -781,7 +781,7 @@ field whose *id* is ``product_name`` (and name is ``product[name]``).
));
}

Then the block name will be ``_product_custom_name_widget``.
Then the block name will be ``_product_custom_name_widget``.

You can also override the markup for an entire field row using the same method:

Expand Down Expand Up @@ -874,10 +874,11 @@ Customizing Error Output
~~~~~~~~~~~~~~~~~~~~~~~~

.. note::
The Form component only handles *how* the validation errors are rendered,
and not the actual validation error messages. The error messages themselves
are determined by the validation constraints you apply to your objects.
For more information, see the article on :doc:`validation </validation>`.

The Form component only handles *how* the validation errors are rendered,
and not the actual validation error messages. The error messages themselves
are determined by the validation constraints you apply to your objects.
For more information, see the article on :doc:`validation </validation>`.

There are many different ways to customize how errors are rendered when a
form is submitted with errors. The error messages for a field are rendered
Expand Down

0 comments on commit 548360a

Please sign in to comment.