Skip to content

Commit c706424

Browse files
committed
Merge branch '2.0'
Conflicts: book/routing.rst cookbook/form/create_custom_field_type.rst cookbook/form/form_collections.rst
2 parents 84cbe90 + 480d574 commit c706424

26 files changed

+179
-193
lines changed

book/controller.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ a controller object. Controllers are also called *actions*.
9494
:linenos:
9595
9696
// src/Acme/HelloBundle/Controller/HelloController.php
97-
9897
namespace Acme\HelloBundle\Controller;
98+
9999
use Symfony\Component\HttpFoundation\Response;
100100
101101
class HelloController
@@ -208,8 +208,8 @@ passed to that method:
208208
209209
<?php
210210
// src/Acme/HelloBundle/Controller/HelloController.php
211-
212211
namespace Acme\HelloBundle\Controller;
212+
213213
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
214214
215215
class HelloController extends Controller
@@ -349,8 +349,8 @@ Add the ``use`` statement atop the ``Controller`` class and then modify the
349349
.. code-block:: php
350350
351351
// src/Acme/HelloBundle/Controller/HelloController.php
352-
353352
namespace Acme\HelloBundle\Controller;
353+
354354
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
355355
use Symfony\Component\HttpFoundation\Response;
356356

book/doctrine.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Without even thinking about Doctrine or databases, you already know that
9393
you need a ``Product`` object to represent those products. Create this class
9494
inside the ``Entity`` directory of your ``AcmeStoreBundle``::
9595

96-
// src/Acme/StoreBundle/Entity/Product.php
96+
// src/Acme/StoreBundle/Entity/Product.php
9797
namespace Acme\StoreBundle\Entity;
9898

9999
class Product
@@ -369,7 +369,7 @@ of the bundle:
369369
use Acme\StoreBundle\Entity\Product;
370370
use Symfony\Component\HttpFoundation\Response;
371371
// ...
372-
372+
373373
public function createAction()
374374
{
375375
$product = new Product();
@@ -1058,7 +1058,7 @@ can avoid the second query by issuing a join in the original query. Add the
10581058
following method to the ``ProductRepository`` class::
10591059

10601060
// src/Acme/StoreBundle/Repository/ProductRepository.php
1061-
1061+
10621062
public function findOneByIdJoinedToCategory($id)
10631063
{
10641064
$query = $this->getManager()
@@ -1067,7 +1067,7 @@ following method to the ``ProductRepository`` class::
10671067
JOIN p.category c
10681068
WHERE p.id = :id'
10691069
)->setParameter('id', $id);
1070-
1070+
10711071
try {
10721072
return $query->getSingleResult();
10731073
} catch (\Doctrine\ORM\NoResultException $e) {

book/forms.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,6 @@ that will house the logic for building the task form:
798798
.. code-block:: php
799799
800800
// src/Acme/TaskBundle/Form/Type/TaskType.php
801-
802801
namespace Acme\TaskBundle\Form\Type;
803802
804803
use Symfony\Component\Form\AbstractType;

book/from_flat_php_to_symfony2.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,8 +543,8 @@ them for you. Here's the same sample application, now built in Symfony2:
543543

544544
<?php
545545
// src/Acme/BlogBundle/Controller/BlogController.php
546-
547546
namespace Acme\BlogBundle\Controller;
547+
548548
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
549549

550550
class BlogController extends Controller

book/page_creation.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ greeted. To create the page, follow the simple two-step process.
4848
``web`` directory of your new Symfony2 project. For detailed information
4949
on this process, see the documentation on the web server you are using.
5050
Here's the relevant documentation page for some web server you might be using:
51-
51+
5252
* For Apache HTTP Server, refer to `Apache's DirectoryIndex documentation`_.
5353
* For Nginx, refer to `Nginx HttpCoreModule location documentation`_.
5454

@@ -209,8 +209,6 @@ inside your ``AcmeHelloBundle``::
209209
// src/Acme/HelloBundle/Controller/HelloController.php
210210
namespace Acme\HelloBundle\Controller;
211211

212-
use Symfony\Component\HttpFoundation\Response;
213-
214212
class HelloController
215213
{
216214
}
@@ -225,8 +223,10 @@ Create the ``indexAction`` method that Symfony will execute when the ``hello``
225223
route is matched::
226224

227225
// src/Acme/HelloBundle/Controller/HelloController.php
226+
namespace Acme\HelloBundle\Controller;
227+
228+
use Symfony\Component\HttpFoundation\Response;
228229

229-
// ...
230230
class HelloController
231231
{
232232
public function indexAction($name)

book/routing.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ pattern that points to a specific PHP class and method:
8080
.. code-block:: php
8181
8282
// src/Acme/BlogBundle/Controller/BlogController.php
83-
8483
namespace Acme\BlogBundle\Controller;
84+
8585
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
8686
8787
class BlogController extends Controller
@@ -824,8 +824,8 @@ The controller might look like this:
824824
.. code-block:: php
825825
826826
// src/Acme/BlogBundle/Controller/BlogController.php
827-
828827
namespace Acme\BlogBundle\Controller;
828+
829829
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
830830
831831
class BlogController extends Controller

book/service_container.rst

Lines changed: 2 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -874,142 +874,10 @@ the framework.
874874
the ``swiftmailer`` key invokes the service extension from the
875875
``SwiftmailerBundle``, which registers the ``mailer`` service.
876876

877-
.. index::
878-
single: Service Container; Advanced configuration
879-
880-
Advanced Container Configuration
881-
--------------------------------
882-
883-
As we've seen, defining services inside the container is easy, generally
884-
involving a ``service`` configuration key and a few parameters. However,
885-
the container has several other tools available that help to *tag* services
886-
for special functionality, create more complex services, and perform operations
887-
after the container is built.
888-
889-
Marking Services as public / private
890-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
891-
892-
When defining services, you'll usually want to be able to access these definitions
893-
within your application code. These services are called ``public``. For example,
894-
the ``doctrine`` service registered with the container when using the DoctrineBundle
895-
is a public service as you can access it via::
896-
897-
$doctrine = $container->get('doctrine');
898-
899-
However, there are use-cases when you don't want a service to be public. This
900-
is common when a service is only defined because it could be used as an
901-
argument for another service.
902-
903-
.. note::
904-
905-
If you use a private service as an argument to more than one other service,
906-
this will result in two different instances being used as the instantiation
907-
of the private service is done inline (e.g. ``new PrivateFooBar()``).
908-
909-
Simply said: A service will be private when you do not want to access it
910-
directly from your code.
911-
912-
Here is an example:
913-
914-
.. configuration-block::
915-
916-
.. code-block:: yaml
917-
918-
services:
919-
foo:
920-
class: Acme\HelloBundle\Foo
921-
public: false
922-
923-
.. code-block:: xml
924-
925-
<service id="foo" class="Acme\HelloBundle\Foo" public="false" />
926-
927-
.. code-block:: php
928-
929-
$definition = new Definition('Acme\HelloBundle\Foo');
930-
$definition->setPublic(false);
931-
$container->setDefinition('foo', $definition);
932-
933-
Now that the service is private, you *cannot* call::
934-
935-
$container->get('foo');
936-
937-
However, if a service has been marked as private, you can still alias it (see
938-
below) to access this service (via the alias).
939-
940-
.. note::
941-
942-
Services are by default public.
943-
944-
Aliasing
945-
~~~~~~~~
946-
947-
When using core or third party bundles within your application, you may want
948-
to use shortcuts to access some services. You can do so by aliasing them and,
949-
furthermore, you can even alias non-public services.
950-
951-
.. configuration-block::
952-
953-
.. code-block:: yaml
954-
955-
services:
956-
foo:
957-
class: Acme\HelloBundle\Foo
958-
bar:
959-
alias: foo
960-
961-
.. code-block:: xml
962-
963-
<service id="foo" class="Acme\HelloBundle\Foo"/>
964-
965-
<service id="bar" alias="foo" />
966-
967-
.. code-block:: php
968-
969-
$definition = new Definition('Acme\HelloBundle\Foo');
970-
$container->setDefinition('foo', $definition);
971-
972-
$containerBuilder->setAlias('bar', 'foo');
973-
974-
This means that when using the container directly, you can access the ``foo``
975-
service by asking for the ``bar`` service like this::
976-
977-
$container->get('bar'); // Would return the foo service
978-
979-
Requiring files
980-
~~~~~~~~~~~~~~~
981-
982-
There might be use cases when you need to include another file just before
983-
the service itself gets loaded. To do so, you can use the ``file`` directive.
984-
985-
.. configuration-block::
986-
987-
.. code-block:: yaml
988-
989-
services:
990-
foo:
991-
class: Acme\HelloBundle\Foo\Bar
992-
file: %kernel.root_dir%/src/path/to/file/foo.php
993-
994-
.. code-block:: xml
995-
996-
<service id="foo" class="Acme\HelloBundle\Foo\Bar">
997-
<file>%kernel.root_dir%/src/path/to/file/foo.php</file>
998-
</service>
999-
1000-
.. code-block:: php
1001-
1002-
$definition = new Definition('Acme\HelloBundle\Foo\Bar');
1003-
$definition->setFile('%kernel.root_dir%/src/path/to/file/foo.php');
1004-
$container->setDefinition('foo', $definition);
1005-
1006-
Notice that symfony will internally call the PHP function require_once
1007-
which means that your file will be included only once per request.
1008-
1009877
.. _book-service-container-tags:
1010878

1011879
Tags (``tags``)
1012-
~~~~~~~~~~~~~~~
880+
---------------
1013881

1014882
In the same way that a blog post on the Web might be tagged with things such
1015883
as "Symfony" or "PHP", services configured in your container can also be
@@ -1077,5 +945,6 @@ Learn more
1077945
* :doc:`/cookbook/controller/service`
1078946
* :doc:`/cookbook/service_container/scopes`
1079947
* :doc:`/cookbook/service_container/compiler_passes`
948+
* :doc:`/components/dependency_injection/advanced`
1080949

1081950
.. _`service-oriented architecture`: http://wikipedia.org/wiki/Service-oriented_architecture

book/testing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ called ``Calculator`` in the ``Utility/`` directory of your bundle::
5353

5454
// src/Acme/DemoBundle/Utility/Calculator.php
5555
namespace Acme\DemoBundle\Utility;
56-
56+
5757
class Calculator
5858
{
5959
public function add($a, $b)

0 commit comments

Comments
 (0)