diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000000..c091839860d --- /dev/null +++ b/.gitignore @@ -0,0 +1,50 @@ +# Compiled source # +################### +*.com +*.class +*.dll +*.exe +*.o +*.so +*.pyc + +# Numerous always-ignore extensions +################### +*.diff +*.err +*.orig +*.log +*.rej +*.swo +*.swp +*.vi +*~ + +*.sass-cache +# Folders to ignore +################### +.hg +.svn +.CVS +# OS or Editor folders +################### +.DS_Store +Icon? +Thumbs.db +ehthumbs.db +nbproject +.cache +.project +.settings +.tmproj +*.esproj +*.sublime-project +*.sublime-workspace +# Dreamweaver added files +################### +_notes +dwsync.xml +# Komodo +################### +*.komodoproject +.komodotools diff --git a/book/controller.rst b/book/controller.rst index 637d6899b87..2a6626f9ad2 100644 --- a/book/controller.rst +++ b/book/controller.rst @@ -420,7 +420,7 @@ object is the end-product of the internal sub-request:: )); // further modify the response or return it directly - + return $response; } @@ -449,7 +449,7 @@ value to each variable. a shortcut for core Symfony2 functionality. A forward can be accomplished directly via the ``http_kernel`` service. A forward returns a ``Response`` object:: - + $httpKernel = $this->container->get('http_kernel'); $response = $httpKernel->forward('AcmeHelloBundle:Hello:fancy', array( 'name' => $name, @@ -488,7 +488,7 @@ The Symfony templating engine is explained in great detail in the The ``renderView`` method is a shortcut to direct use of the ``templating`` service. The ``templating`` service can also be used directly:: - + $templating = $this->get('templating'); $content = $templating->render('AcmeHelloBundle:Hello:index.html.twig', array('name' => $name)); @@ -604,12 +604,12 @@ Let's show an example where we're processing a form submit:: { if ('POST' === $this->get('request')->getMethod()) { // do some sort of processing - + $this->get('session')->setFlash('notice', 'Your changes were saved!'); return new RedirectResponse($this->generateUrl(...)); } - + return $this->render(...); } @@ -628,7 +628,7 @@ could be used to render the message: {% endif %} .. code-block:: php - + hasFlash('notice') ?>
getFlash('notice') ?> @@ -652,7 +652,7 @@ headers and content that's sent back to the client:: // create a simple Response with a 200 status code (the default) $response = new Response('Hello '.$name, 200); - + // create a JSON-response with a 200 status code $response = new Response(json_encode(array('name' => $name))); $response->headers->set('Content-Type', 'application/json'); diff --git a/book/doctrine/dbal.rst b/book/doctrine/dbal.rst index bd6a6c867e7..15093b9c1bc 100644 --- a/book/doctrine/dbal.rst +++ b/book/doctrine/dbal.rst @@ -167,7 +167,7 @@ be added to all configured connections. .. code-block:: php - + // app/config/config.php $container->loadFromExtension('doctrine', array( 'dbal' => array( diff --git a/book/doctrine/model.rst b/book/doctrine/model.rst index 989af738afe..a328abdacce 100644 --- a/book/doctrine/model.rst +++ b/book/doctrine/model.rst @@ -42,42 +42,42 @@ model. If you're building a content management system, then you will need a ``Page`` model. .. code-block:: php - + title = $title; $this->body = $body; $this->createdAt = new \DateTime(); } - + public function setTitle($title) { $this->title = $title; $this->updatedAt = new \DateTime(); } - + public function setBody($body) { $this->body = $body; $this->updatedAt = new \DateTime(); } - + public function getTitle() { return $this->title; } - + public function getBody() { return $this->body; diff --git a/book/forms.rst b/book/forms.rst index 6b215a7ef37..60998182564 100644 --- a/book/forms.rst +++ b/book/forms.rst @@ -36,13 +36,13 @@ going to need to build a form. But before you begin, let's focus on the generic // src/Acme/StoreBundle/Entity/Product.php namespace Acme\StoreBundle\Entity; - + class Product { public $name; - + protected $price; - + public function getPrice() { return $this->price; @@ -59,9 +59,9 @@ going to need to build a form. But before you begin, let's focus on the generic If you're coding along with this example, be sure to create and enable the ``AcmeStoreBundle``. Run the following command and follow the on-screen directions: - + .. code-block:: text - + php app/console init:bundle "Acme\StoreBundle" src/ This type of class is commonly called a "plain-old-PHP-object" because, so far, @@ -141,17 +141,17 @@ helper functions: .. code-block:: html+jinja {# src/Acme/StoreBundle/Resources/views/Default/index.html.twig #} - +
{{ form_widget(form) }} - +
.. code-block:: html+php - + - +
enctype($form) ?> > widget($form) ?> @@ -194,7 +194,7 @@ controller: { // just setup a fresh $product object (no dummy data) $product = new Product(); - + $form = $this->get('form.factory') ->createBuilder('form', $product) ->add('name', 'text') @@ -211,7 +211,7 @@ controller: return $this->redirect($this->generateUrl('store_product_success')); } } - + // ... } @@ -229,7 +229,7 @@ of the ``$product`` object. This all happens via the ``bindRequest()`` method. $product = new Product(); $product->name = 'Test product'; - + $form->bindRequest($this->get('request')); echo $product->name; @@ -334,7 +334,7 @@ number: public static function loadValidatorMetadata(ClassMetadata $metadata) { $metadata->addPropertyConstraint('name', new NotBlank()); - + $metadata->addPropertyConstraint('price', new NotBlank()); $metadata->addPropertyConstraint('price', new Min(0)); } @@ -430,14 +430,14 @@ guess (``text``). The ``createBuilder()`` method takes up to three arguments (but only the first is required): - + * the string ``form`` stands for the what you're building (a form) and is also used as the name of the form. If you look at the generated code, the two fields are named ``name="form[price]"`` and ``name="form[name]"``; - + * The default data to initialize the form fields. This argument can be an associative array or a plain old PHP object like in this example; - + * an array of options for the form. This example is pretty trivial, but field guessing can be a major time saver. @@ -460,7 +460,7 @@ of code. Of course, you'll usually need much more flexibility when rendering: .. code-block:: html+jinja {# src/Acme/StoreBundle/Resources/views/Default/index.html.twig #} - + {{ form_errors(form) }} @@ -473,9 +473,9 @@ of code. Of course, you'll usually need much more flexibility when rendering:
.. code-block:: html+php - + - +
enctype($form) ?>> errors($form) ?> @@ -635,30 +635,30 @@ It can be used to quickly build a form object in the controller: { $product = // ... $form = $this->get('form.factory')->create(new ProductType(), $product); - + // ... } .. note:: You can also set the data on the form via the ``setData()`` method: - + .. code-block:: php - + $form = $this->get('form.factory')->create(new ProductType()); $form->setData($product); If you use the ``setData`` method - and want to take advantage of field type guessing, be sure to add the following to your form class: - + .. code-block:: php - + public function getDefaultOptions(array $options) { return array( 'data_class' => 'Acme\StoreBundle\Entity\Product', ); } - + This is necessary because the object is passed to the form after field type guessing. @@ -740,7 +740,7 @@ The ``Product`` class has a new ``$category`` property, indicating to which ``Category`` it belongs: .. code-block:: php - + class Product { // ... @@ -885,10 +885,10 @@ do this, create a new template file that will store the new markup: .. configuration-block:: .. code-block:: html+jinja - + {# src/Acme/StoreBundle/Resources/views/Form/fields.html.twig #} {% extends 'TwigBundle:Form:div_layout.html.twig' %} - + {% block field_row %} {% spaceless %}
@@ -919,7 +919,7 @@ the form: {# src/Acme/StoreBundle/Resources/views/Default/index.html.twig #} {% form_theme form 'AcmeStoreBundle:Form:fields.html.twig' %} - + The ``form_theme`` tag "imports" the template and uses all of its form-related @@ -1010,18 +1010,18 @@ templates in your application. To automatically include the customized blocks from the ``fields.html.twig`` template created earlier, modify your application configuration file: -.. configuration-block:: +.. configuration-block:: .. code-block:: yaml - + # app/config/config.yml twig: form: resources: ['AcmeStoreBundle:Form:fields.html.twig'] # ... - + .. code-block:: xml - + @@ -1039,18 +1039,18 @@ configuration file: )); Any blocks inside the ``fields.html.twig`` template are now used globally -to define form output. +to define form output. .. sidebar:: Customizing Form Output all in a Single File You can also customize a form block right inside the template where that customization is needed. Note that this method will only work if the template used extends some base template via the ``{% extends %}``: - + .. code-block:: html+jinja - + {% extends '::base.html.twig' %} - + {% form_theme form _self %} {% use 'TwigBundle:Form:div_layout.html.twig' %} @@ -1060,7 +1060,7 @@ to define form output. {% block content %} {# ... #} - + {{ form_row(form.name) }} {% endblock %} @@ -1068,7 +1068,7 @@ to define form output. directly inside the template that will use those customizations. Use this method to quickly make form output customizations that will only ever be needed in a single template. - + The ``use`` tag is also helpful as it gives you access to all of the blocks defined inside ``div_layout.html.twig``. For example, this ``use`` statement is necessary to make the following form customization, as it diff --git a/book/from_flat_php_to_symfony2.rst b/book/from_flat_php_to_symfony2.rst index df71b92304a..315a89e4d5a 100644 --- a/book/from_flat_php_to_symfony2.rst +++ b/book/from_flat_php_to_symfony2.rst @@ -11,7 +11,7 @@ better software than with flat PHP, you'll see for yourself. In this chapter, you'll write a simple application in flat PHP, and then refactor it to be more organized. You'll travel through time, seeing the decisions behind why web development has evolved over the past several years -to where it is now. +to where it is now. By the end, you'll see how Symfony2 can rescue you from mundane tasks and let you take back control of your code. @@ -132,7 +132,7 @@ to the area of *your* code that processes user input and prepares the response. In this case, our controller prepares data from the database and then includes a template to present that data. With the controller isolated, you could easily change *just* the template file if you needed to render the blog -entries in some other format (e.g. ``list.json.php`` for JSON format). +entries in some other format (e.g. ``list.json.php`` for JSON format). Isolating the Application (Domain) Logic ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -575,7 +575,7 @@ now quite a bit simpler: .. code-block:: html+php - + extend('::layout.html.php') ?> set('title', 'List of Posts') ?> diff --git a/book/http_fundamentals.rst b/book/http_fundamentals.rst index ec139cd64d3..705835db3da 100644 --- a/book/http_fundamentals.rst +++ b/book/http_fundamentals.rst @@ -118,7 +118,7 @@ from the xkcd web server: :align: center Translated into HTTP, the response sent back to the browser will look something -like this: +like this: .. code-block:: text @@ -421,7 +421,7 @@ you'll learn how a controller can render templates, allowing your "presentation" code (i.e. anything that actually writes out HTML) to live in a separate template file. This frees up the controller to worry only about the hard stuff: interacting with the database, handling submitted data, or sending -email messages. +email messages. Symfony2: Build your App, not your Tools. ----------------------------------------- diff --git a/book/internals/event_dispatcher.rst b/book/internals/event_dispatcher.rst index c0a77819261..4637c82d81b 100644 --- a/book/internals/event_dispatcher.rst +++ b/book/internals/event_dispatcher.rst @@ -149,7 +149,7 @@ the dispatcher calls the ``myListener::onFooAction`` method and passes the class myListener { // ... - + public function onFooAction(Event $event) { // do something @@ -190,11 +190,11 @@ passes an instance of ``Symfony\Component\HttpKernel\Event\FilterResponseEvent`` So far, you've seen how PHP objects can be registered as listeners. You can also register PHP `Closures`_ as event listeners: - + .. code-block:: php - + use Symfony\Component\EventDispatcher\Event; - + $dispatcher->addListener('onFooAction', function(Event $event) { // will be executed when the onFooAction event is dispatched }); @@ -221,13 +221,13 @@ define and document your event: .. code-block:: php namespace Acme\StoreBundle; - + final class Events { /** * The onStoreOrder event is thrown each time an order is created * in the system. - * + * * The event listener receives an Acme\StoreBundle\Event\FilterOrderEvent * instance. * @@ -258,14 +258,14 @@ object. Create an ``Event`` class that makes this possible: .. code-block:: php namespace Acme\StoreBundle\Event; - + use Symfony\Component\EventDispatcher\Event; use Acme\StoreBundle\Order; - + class FilterOrderEvent extends Event { protected $order; - + public function __construct(Order $order) { $this->order = $order; @@ -275,7 +275,7 @@ object. Create an ``Event`` class that makes this possible: { return $this->order; } - } + } Each listener now has access to to ``Order`` object via the ``getOrder`` method. @@ -297,7 +297,7 @@ each listener of that event: // the order is somehow created or retrieved $order = new Order(); // ... - + // create the FilterOrderEvent and dispatch it $event = new FilterOrderEvent($order); $dispatcher->dispatch(Events::onStoreOrder, $event); @@ -385,7 +385,7 @@ and ``onStoreOrder`` events: .. code-block:: php namespace Acme\StoreBundle\Event; - + use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; @@ -444,7 +444,7 @@ via the :method:`Symfony\\Component\\EventDispatcher\\Event::stopPropagation` me public function onStoreOrder(FilterOrderEvent $event) { // ... - + $event->stopPropagation(); } diff --git a/book/page_creation.rst b/book/page_creation.rst index 2f9fcc3c036..4b3eaa6676c 100644 --- a/book/page_creation.rst +++ b/book/page_creation.rst @@ -82,7 +82,7 @@ of the ``AppKernel`` class: // ... new Acme\StudyBundle\AcmeStudyBundle(), ); - + // ... return $bundles; @@ -464,12 +464,12 @@ about each of these directories in later chapters. or ``require`` statements. Instead, Symfony2 uses the namespace of a class to determine its location and automatically includes the file on your behalf the instant you need a class:: - + $loader->registerNamespaces(array( 'Acme' => __DIR__.'/../src', // ... )); - + With this configuration, Symfony2 will look inside the ``src`` directory for any class in the ``Acme`` namespace (your pretend company's namespace). For autoloading to work, the class name and path to the file must follow @@ -784,9 +784,9 @@ call the ``prod`` front controller instead:: If you open the ``web/app.php`` file, you'll find that it's configured explicitly to use the ``prod`` environment:: - + $kernel = new AppCache(new AppKernel('prod', false)); - + You can create a new front controller for a new environment by copying this file and changing ``prod`` to some other value. diff --git a/book/routing.rst b/book/routing.rst index 20e4ba327a2..d765a3010bf 100644 --- a/book/routing.rst +++ b/book/routing.rst @@ -18,7 +18,7 @@ areas of your application. By the end of this chapter, you'll be able to: * Create complex routes that map to controllers * Generate URLs inside templates and controllers -* Load routing resources from bundles (or anywhere else) +* Load routing resources from bundles (or anywhere else) * Debug your routes .. index:: @@ -80,7 +80,7 @@ pattern that points to a specific PHP class and method: .. code-block:: php // src/Acme/BlogBundle/Controller/BlogController.php - + namespace Acme/BlogBundle/Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; @@ -89,7 +89,7 @@ pattern that points to a specific PHP class and method: public function showAction($slug) { $blog = // use the $slug varible to query the database - + return $this->render('AcmeBlogBundle:Blog:show.html.twig', array( 'blog' => $blog, )); @@ -102,7 +102,7 @@ will be executed and the ``$slug`` variable will be equal to ``my-post``. This is the goal of the Symfony2 router: to map the URL of a request to a controller. Along the way, you'll learn all sorts of tricks that make mapping -even the most complex URLs easy. +even the most complex URLs easy. .. index:: single: Routing; Under the hood @@ -799,10 +799,10 @@ The controller might look like this: .. code-block:: php // src/Acme/BlogBundle/Controller/BlogController.php - + namespace Acme\BlogBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; - + class BlogController extends Controller { public function showAction($slug) @@ -1091,9 +1091,9 @@ method: on server information supplied by PHP. When generating absolute URLs for scripts run from the command line, you'll need to manually set the desired host on the ``Request`` object: - + .. code-block:: php - + $request->headers->set('HOST', 'www.example.com'); .. index:: diff --git a/book/security/acl.rst b/book/security/acl.rst index 9f2dd5dc09e..2143e9f9c84 100644 --- a/book/security/acl.rst +++ b/book/security/acl.rst @@ -64,7 +64,7 @@ First, we need to configure the connection the ACL system is supposed to use: The ACL system requires at least one Doctrine DBAL connection to be configured. However, that does not mean that you have to use Doctrine for mapping your domain objects. You can use whatever mapper you like for your - objects, be it Doctrine ORM, Mongo ODM, Propel, or raw SQL, the choice is + objects, be it Doctrine ORM, Mongo ODM, Propel, or raw SQL, the choice is yours. After the connection is configured, we have to import the database structure. diff --git a/book/security/authentication.rst b/book/security/authentication.rst index 35b973ac936..784d31e2f0b 100644 --- a/book/security/authentication.rst +++ b/book/security/authentication.rst @@ -305,14 +305,14 @@ yourself:: )); } } - + .. note:: - + The ``$error`` variable references an instance of - :class:`Symfony\\Component\\Security\\Core\\Exception\\AuthenticationException`, + :class:`Symfony\\Component\\Security\\Core\\Exception\\AuthenticationException`, or one of its sub-classes. This exception might contain sensitive information, so you should be very careful how much of the contained information you want - to expose on your production system. + to expose on your production system. And the corresponding template might look like this: diff --git a/book/security/config_reference.rst b/book/security/config_reference.rst index acd6aa4c0f2..4e601c82013 100644 --- a/book/security/config_reference.rst +++ b/book/security/config_reference.rst @@ -11,12 +11,12 @@ Configuration Reference # app/config/security.yml security: access_denied_url: /foo/error403 - + access_decision_manager: strategy: affirmative allow_if_all_abstain: false allow_if_equal_granted_denied: true - + acl: connection: default # any name configured in doctrine.dbal section tables: diff --git a/book/security/overview.rst b/book/security/overview.rst index f12a71ec18c..5e9db8f1538 100644 --- a/book/security/overview.rst +++ b/book/security/overview.rst @@ -12,8 +12,8 @@ refers to the process of deciding whether a user is allowed to perform an action or not (authentication is always performed before authorization). This document is a quick overview over these main concepts, but it barely scratches -the surface. If you want to get to know the real power of Symfony2's security -layer, you should also read these more specific documents: +the surface. If you want to get to know the real power of Symfony2's security +layer, you should also read these more specific documents: :doc:`Users `, :doc:`Authentication `, and :doc:`Authorization `. @@ -137,7 +137,7 @@ As you can see, the configuration has four sections: roles. To sum up the workflow, the firewall authenticates the client based on the -submitted credentials and the user created by the user provider. Finally, +submitted credentials and the user created by the user provider. Finally, access control is used to protect specific resources. Authentication diff --git a/book/security/users.rst b/book/security/users.rst index 8e2f32c218e..11ca8004e07 100644 --- a/book/security/users.rst +++ b/book/security/users.rst @@ -44,7 +44,7 @@ The user provider must implement :class:`Symfony\\Component\\Security\\Core\\Exception\\UnsupportedAccountException` exception. * ``supportsClass()``: Receives an account's class and returns whether the class - is supported by the provider. + is supported by the provider. .. tip:: @@ -374,7 +374,7 @@ implement :class:`Symfony\\Component\\Security\\Core\\User\\UserProviderInterfac .. index:: single: Security; Chain Provider - + Chain Provider ~~~~~~~~~~~~~~ @@ -384,7 +384,7 @@ between several other user providers. .. configuration-block:: .. code-block:: yaml - + # app/config/security.yml security: providers: @@ -395,9 +395,9 @@ between several other user providers. foo: { password: test } dao_provider: entity: { class: Acme\MyBundle\Entity\User, property: username } - + .. code-block:: xml - + @@ -408,9 +408,9 @@ between several other user providers. - + .. code-block:: php - + // app/config/security.php $container->loadFromExtension('security', array( 'providers' => array( @@ -443,11 +443,11 @@ user providers suits your needs. In this example, we will set-up a user provider using Doctrine Mongo DB. We assume that you have the DoctrineMongoDBBundle already installed. This bundle -ships with a user provider similar to the built-in entity provider, but for +ships with a user provider similar to the built-in entity provider, but for documents. First, we need to wire the user provider service with the Dependency Injection -container, and second, we need to define this custom user provider in the +container, and second, we need to define this custom user provider in the security configuration. .. configuration-block:: @@ -459,12 +459,12 @@ security configuration. my.mongodb.provider: parent: doctrine.odm.mongodb.security.user.provider arguments: [Acme\MyBundle\Document\User, username] - + security: providers: custom_provider: id: my.mongodb.provider - + .. code-block:: xml @@ -474,7 +474,7 @@ security configuration. username - + @@ -487,7 +487,7 @@ security configuration. ->addArgument('Acme\MyBundle\Document\User') ->addArgument('username') ; - + $container->loadFromExtension('security', array( 'providers' => array( 'custom_provider' => array( diff --git a/book/templating.rst b/book/templating.rst index 83d2942e993..4a7d40d2d59 100644 --- a/book/templating.rst +++ b/book/templating.rst @@ -115,16 +115,16 @@ Throughout this chapter, template examples will be shown in both Twig and PHP. not program logic. The more you use Twig, the more you'll appreciate and benefit from this distinction. And of course, you'll be loved by web designers everywhere. - + Twig can also do things that PHP can't, such as true template inheritance (Twig templates compile down to PHP classes that inherit from each other), whitespace control, sandboxing, and the inclusion of custom functions and filters that only affect templates. Twig contains little features that make writing templates easier and more concise. Take the following example, which combines a loop with a logical ``if`` statement: - + .. code-block:: html+jinja - +
    {% for user in users %}
  • {{ user.username }}
  • @@ -1080,7 +1080,7 @@ pattern is to do the following: public function indexAction() { $format = $this->get('request')->getRequestFormat(); - + return $this->render('AcmeBlogBundle:Blog:index.'.$format.'.twig'); } diff --git a/book/testing.rst b/book/testing.rst index 1e5f9f194c8..8ff7c6ec68b 100644 --- a/book/testing.rst +++ b/book/testing.rst @@ -693,7 +693,7 @@ The Client used by functional tests creates a Kernel that runs in a special type="stream" path="%kernel.logs_dir%/%kernel.environment%.log" level="debug" - /> + /> @@ -717,7 +717,7 @@ The Client used by functional tests creates a Kernel that runs in a special 'main' => array('type' => 'stream', 'path' => '%kernel.logs_dir%/%kernel.environment%.log' 'level' => 'debug') - + ))); You can also change the default environment (``test``) and override the diff --git a/book/translation.rst b/book/translation.rst index 18aab64b840..d5f0605c542 100644 --- a/book/translation.rst +++ b/book/translation.rst @@ -380,7 +380,7 @@ Symfony2 will discover these files and use them when translating either read "Symfony2 is really great" in the default locale. The choice of which method to use is entirely up to you, but the "keyword" - format is often recommended. + format is often recommended. Additionally, the ``php`` and ``yaml`` file formats support nested ids to avoid repeating yourself if you use keywords instead of real text for your diff --git a/contributing/code/conventions.rst b/contributing/code/conventions.rst index 40c79e2d165..e0990ff9501 100644 --- a/contributing/code/conventions.rst +++ b/contributing/code/conventions.rst @@ -72,7 +72,7 @@ must be used instead (where ``XXX`` is the name of the related thing): .. note:: - While "setXXX" and "replaceXXX" are very similar, there is one notable - difference: "setXXX" may replace, or add new elements to the relation. - "replaceXXX" on the other hand is specifically forbidden to add new + While "setXXX" and "replaceXXX" are very similar, there is one notable + difference: "setXXX" may replace, or add new elements to the relation. + "replaceXXX" on the other hand is specifically forbidden to add new elements, but most throw an exception in these cases. diff --git a/contributing/documentation/format.rst b/contributing/documentation/format.rst index 42b6da297d9..bf635ef4673 100644 --- a/contributing/documentation/format.rst +++ b/contributing/documentation/format.rst @@ -136,17 +136,17 @@ Installing the configuration-block Sphinx extension ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Download the extension from the `configuration-block source`_ repository - + * Copy the ``configurationblock.py`` to the ``_exts`` folder under your source folder (where ``conf.py`` is located) - + * Add the following to the ``conf.py`` file: .. code-block:: py - + # ... sys.path.append(os.path.abspath('_exts')) - + # ... # add configurationblock to the list of extensions extensions = ['configurationblock'] diff --git a/contributing/map.rst.inc b/contributing/map.rst.inc index 36b21f06665..df55c2ff23f 100644 --- a/contributing/map.rst.inc +++ b/contributing/map.rst.inc @@ -1,18 +1,18 @@ * **Code**: - * :doc:`Bugs ` | - * :doc:`Patches ` | - * :doc:`Security ` | - * :doc:`Tests ` | - * :doc:`Coding Standards` | - * :doc:`Code Conventions` | + * :doc:`Bugs ` | + * :doc:`Patches ` | + * :doc:`Security ` | + * :doc:`Tests ` | + * :doc:`Coding Standards` | + * :doc:`Code Conventions` | * :doc:`License ` * **Documentation**: - * :doc:`Overview ` | - * :doc:`Format ` | - * :doc:`Translations ` | + * :doc:`Overview ` | + * :doc:`Format ` | + * :doc:`Translations ` | * :doc:`License ` * **Community**: diff --git a/cookbook/configuration/environments.rst b/cookbook/configuration/environments.rst index 3beaa5cad57..2b3fefbc9bb 100644 --- a/cookbook/configuration/environments.rst +++ b/cookbook/configuration/environments.rst @@ -37,7 +37,7 @@ class: // app/AppKernel.php // ... - + class AppKernel extends Kernel { // ... @@ -259,7 +259,7 @@ The best way to accomplish this is via a new environment called, for example, .. code-block:: php // app/config/config_benchmark.php - + $loader->import('config_prod.php') $container->loadFromExtension('framework', array( @@ -301,7 +301,7 @@ The new environment is now accessible via:: about the application or underlying infrastructure. To be sure these environments aren't accessible, the front controller is usually protected from external IP addresses via the following code at the top of the controller: - + .. code-block:: php if (!in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1'))) { diff --git a/cookbook/event_dispatcher/class_extension.rst b/cookbook/event_dispatcher/class_extension.rst index de57840190f..cbf7a4637fc 100644 --- a/cookbook/event_dispatcher/class_extension.rst +++ b/cookbook/event_dispatcher/class_extension.rst @@ -40,15 +40,15 @@ pattern of class extension: class HandleUndefinedMethodEvent extends Event { protected $subject; - + protected $method; - + protected $arguments; - + protected $returnValue; - + protected $isProcessed = false; - + public function __construct($subject, $method, $arguments) { $this->subject = $subject; diff --git a/cookbook/form/twig_form_customization.rst b/cookbook/form/twig_form_customization.rst index ad0eaf0464c..401aede1abd 100644 --- a/cookbook/form/twig_form_customization.rst +++ b/cookbook/form/twig_form_customization.rst @@ -66,7 +66,7 @@ For example, when the widget of a ``text`` type field is rendered, an ``input`` .. code-block:: html+jinja {{ form_widget(form.name) }} - + Internally, Symfony uses the ``text_widget`` block from the ``div_layout.html.twig`` @@ -104,12 +104,12 @@ When rendering a form, you can choose which form theme(s) you want to apply. In this example, the customized block name is ``text_widget`` because you want to override the HTML ``widget`` for all ``text`` field types. If you need to customize textarea fields, you would customize ``textarea_widget``. - + As you can see, the block name is a combination of the field type and which part of the field is being rendered (e.g. ``widget``, ``label``, ``errors``, ``row``). As such, to customize how errors are rendered for just input ``text`` fields, you should customize the ``text_errors`` block. - + More commonly, however, you'll want to customize how errors are displayed across *all* fields. You can do this by customizing the ``field_errors`` block. This takes advantage of field type inheritance. Specifically, @@ -166,7 +166,7 @@ directly in the template that's actually rendering the form. {% block content %} {# render the form #} - + {{ form_row(form.name) }} {% endblock %} @@ -190,11 +190,11 @@ several (or all) forms in your application, read on to the next section. .. note:: Be sure also to include the ``use`` statement somewhere in your template when using this method: - + .. code-block:: jinja - + {% use 'TwigBundle:Form:div_layout.html.twig' %} - + This "imports" all of the blocks from the base ``div_layout.html.twig`` template, which gives you access to the ``attributes`` block. In general, the ``use`` tag is helpful when your template *already* extends a base @@ -237,7 +237,7 @@ tell Symfony to use the template via the ``form_theme`` tag: .. code-block:: html+jinja {% form_theme form 'AcmeDemoBundle:Form:fields.html.twig' %} - + {{ form_widget(form.name) }} When the ``form.name`` widget is rendered, Symfony will use the ``text_widget`` @@ -305,18 +305,18 @@ If you'd like a certain form customization to be global to your application, you can accomplish this by making the form customizations to an external template and then importing it inside your application configuration: -.. configuration-block:: +.. configuration-block:: .. code-block:: yaml - + # app/config/config.yml twig: form: resources: ['AcmeDemoBundle:Form:fields.html.twig'] # ... - + .. code-block:: xml - + @@ -356,7 +356,7 @@ part of the field is being customized. For example:
{% endblock %} - + {{ form_widget(form.name) }} Here, the ``_product_name_widget`` defines the template to use for the field @@ -382,7 +382,7 @@ You can also override the markup for an entire field row using the same method: {{ form_widget(form) }}
{% endblock %} - + {{ form_row(form.name) }} Other Common Customizations diff --git a/cookbook/security/voters.rst b/cookbook/security/voters.rst index 599abd2a2d3..dc506a5b884 100644 --- a/cookbook/security/voters.rst +++ b/cookbook/security/voters.rst @@ -46,8 +46,8 @@ values: * ``VoterInterface::ACCESS_DENIED``: The user is not allowed to access the application In this example, we will check if the user's IP address matches against a list of -blacklisted addresses. If the user's IP is blacklisted, we will return -``VoterInterface::ACCESS_DENIED``, otherwise we will return +blacklisted addresses. If the user's IP is blacklisted, we will return +``VoterInterface::ACCESS_DENIED``, otherwise we will return ``VoterInterface::ACCESS_ABSTAIN`` as this voter's purpose is only to deny access, not to grant access. diff --git a/cookbook/symfony1.rst b/cookbook/symfony1.rst index 15708e39058..7cace72012f 100644 --- a/cookbook/symfony1.rst +++ b/cookbook/symfony1.rst @@ -225,7 +225,7 @@ In Symfony2, the bundles are activated inside the application kernel:: // ... new Acme\HelloBundle\AcmeHelloBundle(), ); - + return $bundles; } diff --git a/cookbook/templating/PHP.rst b/cookbook/templating/PHP.rst index ab54ca8590b..9d61a7ba57d 100644 --- a/cookbook/templating/PHP.rst +++ b/cookbook/templating/PHP.rst @@ -18,7 +18,7 @@ your application configuration file: .. configuration-block:: .. code-block:: yaml - + # app/config/config.yml framework: # ... @@ -42,7 +42,7 @@ your application configuration file: 'templating' => array( 'engines' => array('twig', 'php'), ), - )); + )); You can now render a PHP template instead of a Twig one simply by using the ``.php`` extension in the template name instead of ``.twig``. The controller diff --git a/glossary.rst b/glossary.rst index e6cd820229e..aa84723531d 100644 --- a/glossary.rst +++ b/glossary.rst @@ -53,7 +53,7 @@ Glossary an application. Instead of creating services directly, the developer *trains* the service container (via configuration) on how to create the services. The service container takes care of lazily instantiating - and injecting dependent services. See :doc:`/book/service_container` + and injecting dependent services. See :doc:`/book/service_container` chapter. HTTP Specification @@ -109,7 +109,7 @@ Glossary application or for just a part of it. See the :doc:`book/security/overview` chapters. - YAML + YAML *YAML* is a recursive acronym for "YAML Ain't a Markup Language". It's a lightweight, humane data serialization language used extensively in Symfony2's configuration files. See the :doc:`reference/YAML` reference diff --git a/quick_tour/the_controller.rst b/quick_tour/the_controller.rst index 2d5cf289bce..c460c1e8b3a 100644 --- a/quick_tour/the_controller.rst +++ b/quick_tour/the_controller.rst @@ -235,8 +235,8 @@ In this example, the resource will be cached for a day. But you can also use validation instead of expiration or a combination of both if that fits your needs better. -Resource caching is managed by the Symfony2 built-in reverse proxy. But because -caching is managed using regular HTTP cache headers, you can replace the +Resource caching is managed by the Symfony2 built-in reverse proxy. But because +caching is managed using regular HTTP cache headers, you can replace the built-in reverse proxy with Varnish or Squid and easily scale your application. .. note:: diff --git a/reference/constraints.rst b/reference/constraints.rst index db01c247d8a..aabd2c5af08 100644 --- a/reference/constraints.rst +++ b/reference/constraints.rst @@ -27,7 +27,7 @@ Validation Constraints Reference The Validator is designed to validate objects against *constraints*. In real life, a constraint could be: "The cake must not be burned". In -Symfony2, constraints are similar: They are assertions that a condition is +Symfony2, constraints are similar: They are assertions that a condition is true. Supported Constraints diff --git a/reference/constraints/Choice.rst b/reference/constraints/Choice.rst index e3878ed4f10..960fb26f832 100644 --- a/reference/constraints/Choice.rst +++ b/reference/constraints/Choice.rst @@ -32,10 +32,10 @@ Available Options * ``callback``: [type: string|array] This is a static callback method that can be used instead of the ``choices`` option to return the choices array. - + If you pass a string method name (e.g. ``getGenders``), that static method will be called on the validated class. - + If you pass an array (e.g. ``array('Util', 'getGenders')``), it follows the normal callable syntax where the first argument is the class name and the second argument is the method name. @@ -119,11 +119,11 @@ as an array. // src/Acme/HelloBundle/Author.php use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints\Choice; - + class Author { protected $gender; - + public static function loadValidatorMetadata(ClassMetadata $metadata) { $metadata->addPropertyConstraint('gender', new Choice( diff --git a/reference/constraints/Collection.rst b/reference/constraints/Collection.rst index e6f115e89a6..34c84138695 100644 --- a/reference/constraints/Collection.rst +++ b/reference/constraints/Collection.rst @@ -29,8 +29,8 @@ Options Example: -------- -Let's validate an array with two indexes ``firstName`` and ``lastName``. The -value of ``firstName`` must not be blank, while the value of ``lastName`` must +Let's validate an array with two indexes ``firstName`` and ``lastName``. The +value of ``firstName`` must not be blank, while the value of ``lastName`` must not be blank with a minimum length of four characters. Furthermore, both keys may not exist in the array. @@ -96,11 +96,11 @@ may not exist in the array. use Symfony\Component\Validator\Constraints\NotNull; use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\MinLength; - + class Author { private $options = array(); - + public static function loadValidatorMetadata(ClassMetadata $metadata) { $metadata->addPropertyConstraint('options', new Collection(array( diff --git a/reference/constraints/File.rst b/reference/constraints/File.rst index f202485fcaf..c4fd786c71a 100644 --- a/reference/constraints/File.rst +++ b/reference/constraints/File.rst @@ -68,11 +68,11 @@ not exceed a maximum size of 128 kilobytes and is a PDF document. // src/Acme/HelloBundle/Author.php use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints\File; - + class Author { private $filename; - + public static function loadValidatorMetadata(ClassMetadata $metadata) { $metadata->addPropertyConstraint('filename', new File(array( diff --git a/reference/constraints/MaxLength.rst b/reference/constraints/MaxLength.rst index 00eb4871799..f67ac586de6 100644 --- a/reference/constraints/MaxLength.rst +++ b/reference/constraints/MaxLength.rst @@ -37,7 +37,7 @@ Basic Usage properties: summary: - MaxLength: 100 - + .. code-block:: xml diff --git a/reference/constraints/MinLength.rst b/reference/constraints/MinLength.rst index e0e3822cb3e..979134ac812 100644 --- a/reference/constraints/MinLength.rst +++ b/reference/constraints/MinLength.rst @@ -37,7 +37,7 @@ Basic Usage properties: firstName: - MinLength: 3 - + .. code-block:: xml diff --git a/reference/constraints/True.rst b/reference/constraints/True.rst index 8d8ae61ef1e..a77f2ee2b64 100644 --- a/reference/constraints/True.rst +++ b/reference/constraints/True.rst @@ -77,11 +77,11 @@ Then you can constrain this method with ``True``. // src/Acme/HelloBundle/Author.php use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints\True; - + class Author { protected $token; - + public static function loadValidatorMetadata(ClassMetadata $metadata) { $metadata->addGetterConstraint('tokenValid', new True(array( diff --git a/reference/constraints/Type.rst b/reference/constraints/Type.rst index fcbc669e1e0..09fb1805799 100644 --- a/reference/constraints/Type.rst +++ b/reference/constraints/Type.rst @@ -18,9 +18,9 @@ Options * `array `_ * `bool `_ * `callable `_ - * `float `_ + * `float `_ * `double `_ - * `int `_ + * `int `_ * `integer `_ * `long `_ * `null `_ diff --git a/reference/constraints/Valid.rst b/reference/constraints/Valid.rst index 9706030b68a..8f2b01d8a33 100644 --- a/reference/constraints/Valid.rst +++ b/reference/constraints/Valid.rst @@ -110,7 +110,7 @@ their properties. Furthermore, ``Author`` stores an ``Address`` instance in the * @assert:NotBlank */ protected $lastName; - + protected $address; } @@ -120,13 +120,13 @@ their properties. Furthermore, ``Author`` stores an ``Address`` instance in the use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\MaxLength; - + class Address { protected $street; protected $zipCode; - + public static function loadValidatorMetadata(ClassMetadata $metadata) { $metadata->addPropertyConstraint('street', new NotBlank()); @@ -139,15 +139,15 @@ their properties. Furthermore, ``Author`` stores an ``Address`` instance in the use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\MinLength; - + class Author { protected $firstName; protected $lastName; - + protected $address; - + public static function loadValidatorMetadata(ClassMetadata $metadata) { $metadata->addPropertyConstraint('firstName', new NotBlank()); @@ -185,7 +185,7 @@ invalid address. To prevent that, we add the ``Valid`` constraint to the class Author { /* ... */ - + /** * @assert:Valid */ @@ -197,11 +197,11 @@ invalid address. To prevent that, we add the ``Valid`` constraint to the // src/Acme/HelloBundle/Author.php use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints\Valid; - + class Author { protected $address; - + public static function loadValidatorMetadata(ClassMetadata $metadata) { $metadata->addPropertyConstraint('address', new Valid()); diff --git a/reference/forms/types/birthday.rst b/reference/forms/types/birthday.rst index 08994874413..26ddcfc8427 100644 --- a/reference/forms/types/birthday.rst +++ b/reference/forms/types/birthday.rst @@ -37,19 +37,19 @@ Options ------- * ``widget`` [type: string, default: ``choice``] - Type of widget used for this form type. Can be ``text`` or ``choice``. - + Type of widget used for this form type. Can be ``text`` or ``choice``. + * ``text``: renders a single input of type text. User's input is validated based on the ``format`` option. * ``choice``: renders three select inputs. The order of the selects is defined in the ``pattern`` option. - + * ``input`` [type: string, default: datetime] The value of the input for the widget. Can be ``string``, ``datetime`` or ``array``. The form type input value will be returned in the format specified. The input of April 21th, 2011 as an array would return: - + .. code-block:: php array('month' => 4, 'day' => 21, 'year' => 2011 ) @@ -64,7 +64,7 @@ Options Option passed to the IntlDateFormatter class, used to transform user input into the proper format. This is critical when the ``widget`` option is set to ``text``, and will define how to transform the input. - + * ``pattern`` [type: string, default: null] This option is only relevant when the ``widget`` is set to ``choice``. The default pattern is based off the ``format`` option, and tries to diff --git a/reference/forms/types/choice.rst b/reference/forms/types/choice.rst index a1bcff1ee8e..719dfb2c7d8 100644 --- a/reference/forms/types/choice.rst +++ b/reference/forms/types/choice.rst @@ -69,7 +69,7 @@ the field: {{ form_widget(form.foo_choices, { 'empty_value': 'Choose an option' }) }} .. code-block:: php - + widget($form['foo_choices'], array('empty_value' => 'Choose an option')) ?> Options @@ -79,9 +79,9 @@ Options This is the most basic way to specify the choices that should be used by this field. The ``choices`` option is an array, where the array key is the item value and the array value is the item's label: - + .. code-block:: php - + $builder->add('gender', 'choice', array( 'choices' => array('m' => 'Male', 'f' => 'Female') )); diff --git a/reference/forms/types/date.rst b/reference/forms/types/date.rst index 822970fc1c2..83e297cfcd0 100644 --- a/reference/forms/types/date.rst +++ b/reference/forms/types/date.rst @@ -69,8 +69,8 @@ Options ------- * ``widget`` [type: string, default: ``choice``] - Type of widget used for this form type. Can be ``text`` or ``choice``. - + Type of widget used for this form type. Can be ``text`` or ``choice``. + * ``text``: renders a single input of type text. User's input is validated based on the ``format`` option. @@ -83,7 +83,7 @@ Options The value of the input for the widget. Can be ``string``, ``datetime`` or ``array``. The form type input value will be returned in the format specified. The input of ``April 21th, 2011`` as an array would return: - + .. code-block:: php array('month' => 4, 'day' => 21, 'year' => 2011 ) @@ -98,7 +98,7 @@ Options Option passed to the IntlDateFormatter class, used to transform user input into the proper format. This is critical when the ``widget`` option is set to ``text``, and will define how to transform the input. - + * ``pattern`` [type: string, default: null] This option is only relevant when the ``widget`` is set to ``choice``. The default pattern is based off the ``format`` option, and tries to diff --git a/reference/forms/types/integer.rst b/reference/forms/types/integer.rst index 269c28c2f5b..eee12f43ba3 100644 --- a/reference/forms/types/integer.rst +++ b/reference/forms/types/integer.rst @@ -33,7 +33,7 @@ Options By default, if the user enters a non-integer number, it will be rounded down. There are several other rounding methods, and each is a constant on the :class:`Symfony\\Component\\Form\\DataTransformer\\IntegerToLocalizedStringTransformer`: - + * ``IntegerToLocalizedStringTransformer::ROUND_DOWN`` Rounding mode to round towards zero. * ``IntegerToLocalizedStringTransformer::ROUND_FLOOR`` diff --git a/reference/forms/types/money.rst b/reference/forms/types/money.rst index f6fb4bb5a20..2ae7163d206 100644 --- a/reference/forms/types/money.rst +++ b/reference/forms/types/money.rst @@ -36,16 +36,16 @@ Options the currency symbol that should be shown by the text box. Depending on the currency - the currency symbol may be shown before or after the input text field. - + This can also be set to false to hide the currency symbol. * ``divisor`` [type: integer, default: ``1``] If, for some reason, you need to divide your starting value by a number before rendering it to the user, you can use the ``divisor`` option. For example: - + .. code-block:: php - + $builder->add('price', 'money', array( 'divisor' => 100, )); diff --git a/reference/forms/types/number.rst b/reference/forms/types/number.rst index 70cf2356404..2bbc4585a25 100644 --- a/reference/forms/types/number.rst +++ b/reference/forms/types/number.rst @@ -37,7 +37,7 @@ Options If a submitted number needs to be rounded (based on the ``precision`` option), you have several configurable options for that rounding. Each option is a constant on the :class:`Symfony\\Component\\Form\\DataTransformer\\IntegerToLocalizedStringTransformer`: - + * ``IntegerToLocalizedStringTransformer::ROUND_DOWN`` Rounding mode to round towards zero. * ``IntegerToLocalizedStringTransformer::ROUND_FLOOR`` diff --git a/reference/forms/types/options/label.rst.inc b/reference/forms/types/options/label.rst.inc index c247e948a3a..5471b720e85 100644 --- a/reference/forms/types/options/label.rst.inc +++ b/reference/forms/types/options/label.rst.inc @@ -2,7 +2,7 @@ Sets the label that will be used when rendering the field. If blank, the label will be auto-generated based on the name of the field. The label can also be directly set inside the template: - + .. code-block:: jinja - + {{ render_label(form.name, 'Name') }} \ No newline at end of file diff --git a/reference/forms/types/options/preferred_choices.rst.inc b/reference/forms/types/options/preferred_choices.rst.inc index b449440ac20..b55a1c50084 100644 --- a/reference/forms/types/options/preferred_choices.rst.inc +++ b/reference/forms/types/options/preferred_choices.rst.inc @@ -3,14 +3,14 @@ will be moved to the top of the select menu. The following would move the "Baz" option to the top, with a visual separator between it and the rest of the options: - + .. code-block:: php - + $builder->add('foo_choices', 'choice', array( 'choices' => array('foo' => 'Foo', 'bar' => 'Bar', 'baz' => 'Baz'), 'preferred_choices' => array('baz'), )); - + Note that preferred choices are only meaningful when rendering as a ``select`` element (i.e. ``expanded`` is false). The preferred choices and normal choices are separated visually by a set of dotted lines @@ -18,11 +18,11 @@ the field: .. configuration-block:: - + .. code-block:: jinja - + {{ form_widget(form.foo_choices, { 'separator': '=====' }) }} .. code-block:: php - + widget($form['foo_choices'], array('separator' => '=====')) ?> diff --git a/reference/forms/types/password.rst b/reference/forms/types/password.rst index 2c8cd3db286..fa7278ead5c 100644 --- a/reference/forms/types/password.rst +++ b/reference/forms/types/password.rst @@ -29,7 +29,7 @@ Options If set to true, the field will *always* render blank, even if the corresponding field has a value. When set to false, the password field will be rendered with the ``value`` attribute set to its true value. - + Put simply, if for some reason you want to render your password field *with* the password value already entered into the box, set this to false. diff --git a/reference/forms/types/percent.rst b/reference/forms/types/percent.rst index 28faca630fc..0e1ad5fb983 100644 --- a/reference/forms/types/percent.rst +++ b/reference/forms/types/percent.rst @@ -33,7 +33,7 @@ Options This controls how your data is stored on your object. For example, a percentage corresponding to "55%", might be stored as ``.55`` or ``55`` on your object. The two "types" handle these two cases: - + * ``fractional`` If your data is stored as a decimal (e.g. ``.55``), use this type. The data will be multiplied by ``100`` before being shown to the diff --git a/reference/forms/types/textarea.rst b/reference/forms/types/textarea.rst index e99c4e36d09..9c270120f44 100644 --- a/reference/forms/types/textarea.rst +++ b/reference/forms/types/textarea.rst @@ -4,7 +4,7 @@ textarea Field Type =================== -Renders a ``textarea`` HTML element. +Renders a ``textarea`` HTML element. +-------------+------------------------------------------------------------------------+ | Rendered as | ``textarea`` field | diff --git a/reference/forms/types/time.rst b/reference/forms/types/time.rst index 19d217dea11..10ee91cc322 100644 --- a/reference/forms/types/time.rst +++ b/reference/forms/types/time.rst @@ -64,15 +64,15 @@ Options ------- * ``widget`` [type: string, default: ``choice``] - Type of widget used for this form type. Can be ``text`` or ``choice``. - + Type of widget used for this form type. Can be ``text`` or ``choice``. + * ``text``: renders a single input of type text. User's input is validated based on the ``format`` option. * ``choice``: renders two select inputs (three select inputs if ``with_seconds`` is set to ``true``). * ``input`` [type: string, default: ``datetime``] - The value of the input for the widget. Can be ``string``, ``datetime`` or ``array``. The form type input value will be returned + The value of the input for the widget. Can be ``string``, ``datetime`` or ``array``. The form type input value will be returned in the format specified. The value "12:30" with the ``input`` option set to ``array`` would return: - + .. code-block:: php array('hour' => '12', 'minute' => '30' )