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

Skip to content

Commit d8ac9ba

Browse files
committed
Merge branch '2.0' into 2.1
Conflicts: book/doctrine.rst
2 parents 5b7f8fb + 9c0a86d commit d8ac9ba

File tree

8 files changed

+66
-63
lines changed

8 files changed

+66
-63
lines changed

book/doctrine.rst

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ persist it to the database and fetch it back out.
3434

3535
If you want to follow along with the example in this chapter, create
3636
an ``AcmeStoreBundle`` via:
37-
37+
3838
.. code-block:: bash
39-
39+
4040
$ php app/console generate:bundle --namespace=Acme/StoreBundle
4141
4242
Configuring the Database
@@ -63,9 +63,9 @@ information. By convention, this information is usually configured in an
6363
Defining the configuration via ``parameters.yml`` is just a convention.
6464
The parameters defined in that file are referenced by the main configuration
6565
file when setting up Doctrine:
66-
66+
6767
.. code-block:: yaml
68-
68+
6969
# app/config/config.yml
7070
doctrine:
7171
dbal:
@@ -74,13 +74,20 @@ information. By convention, this information is usually configured in an
7474
dbname: %database_name%
7575
user: %database_user%
7676
password: %database_password%
77-
77+
7878
By separating the database information into a separate file, you can
7979
easily keep different versions of the file on each server. You can also
8080
easily store database configuration (or any sensitive information) outside
8181
of your project, like inside your Apache configuration, for example. For
8282
more information, see :doc:`/cookbook/configuration/external_parameters`.
8383

84+
Now that Doctrine knows about your database, you can have it create the database
85+
for you:
86+
87+
.. code-block:: bash
88+
89+
$ php app/console doctrine:database:create
90+
8491
.. sidebar:: Setting Up The Database
8592

8693
One mistake even seasoned developers make when starting a Symfony2 project
@@ -91,8 +98,8 @@ information. By convention, this information is usually configured in an
9198

9299
.. code-block:: bash
93100
94-
$ app/console doctrine:database:drop --force
95-
$ app/console doctrine:database:create
101+
$ php app/console doctrine:database:drop --force
102+
$ php app/console doctrine:database:create
96103
97104
There's no way to configure these defaults inside Doctrine, as it tries to be
98105
as agnostic as possible in terms of environment configuration. One way to solve
@@ -102,17 +109,10 @@ information. By convention, this information is usually configured in an
102109
your configuration file (typically ``my.cnf``):
103110

104111
.. code-block:: ini
105-
112+
106113
[mysqld]
107114
collation-server = utf8_general_ci
108-
character-set-server = utf8
109-
110-
Now that Doctrine knows about your database, you can have it create the database
111-
for you:
112-
113-
.. code-block:: bash
114-
115-
$ php app/console doctrine:database:create
115+
character-set-server = utf8
116116
117117
Creating an Entity Class
118118
~~~~~~~~~~~~~~~~~~~~~~~~
@@ -143,9 +143,9 @@ just a simple PHP class.
143143

144144
Once you learn the concepts behind Doctrine, you can have Doctrine create
145145
this entity class for you:
146-
146+
147147
.. code-block:: bash
148-
148+
149149
$ php app/console doctrine:generate:entity --entity="AcmeStoreBundle:Product" --fields="name:string(255) price:float description:text"
150150
151151
.. index::
@@ -442,9 +442,9 @@ Let's walk through this example:
442442
In fact, since Doctrine is aware of all your managed entities, when you
443443
call the ``flush()`` method, it calculates an overall changeset and executes
444444
the most efficient query/queries possible. For example, if you persist a
445-
total of 100 ``Product`` objects and then subsequently call ``flush()``,
446-
Doctrine will create a *single* prepared statement and re-use it for each
447-
insert. This pattern is called *Unit of Work*, and it's used because it's
445+
total of 100 ``Product`` objects and then subsequently call ``flush()``,
446+
Doctrine will create a *single* prepared statement and re-use it for each
447+
insert. This pattern is called *Unit of Work*, and it's used because it's
448448
fast and efficient.
449449

450450
When creating or updating objects, the workflow is always the same. In the
@@ -469,7 +469,7 @@ on its ``id`` value::
469469
$product = $this->getDoctrine()
470470
->getRepository('AcmeStoreBundle:Product')
471471
->find($id);
472-
472+
473473
if (!$product) {
474474
throw $this->createNotFoundException('No product found for id '.$id);
475475
}
@@ -591,7 +591,7 @@ You've already seen how the repository object allows you to run basic queries
591591
without any work::
592592

593593
$repository->find($id);
594-
594+
595595
$repository->findOneByName('Foo');
596596

597597
Of course, Doctrine also allows you to write more complex queries using the
@@ -613,7 +613,7 @@ a controller, do the following::
613613
$query = $em->createQuery(
614614
'SELECT p FROM AcmeStoreBundle:Product p WHERE p.price > :price ORDER BY p.price ASC'
615615
)->setParameter('price', '19.99');
616-
616+
617617
$products = $query->getResult();
618618

619619
If you're comfortable with SQL, then DQL should feel very natural. The biggest
@@ -634,10 +634,10 @@ for just one object, you can use the ``getSingleResult()`` method instead::
634634
need to wrap it in a try-catch block and ensure that only one result is
635635
returned (if you're querying on something that could feasibly return
636636
more than one result)::
637-
637+
638638
$query = $em->createQuery('SELECT ...')
639639
->setMaxResults(1);
640-
640+
641641
try {
642642
$product = $query->getSingleResult();
643643
} catch (\Doctrine\Orm\NoResultException $e) {
@@ -655,7 +655,7 @@ covered later), group, etc. For more information, see the official Doctrine
655655
Take note of the ``setParameter()`` method. When working with Doctrine,
656656
it's always a good idea to set any external values as "placeholders",
657657
which was done in the above query:
658-
658+
659659
.. code-block:: text
660660
661661
... WHERE p.price > :price ...
@@ -691,7 +691,7 @@ type the method names. From inside a controller::
691691
->setParameter('price', '19.99')
692692
->orderBy('p.price', 'ASC')
693693
->getQuery();
694-
694+
695695
$products = $query->getResult();
696696

697697
The ``QueryBuilder`` object contains every method necessary to build your
@@ -826,16 +826,16 @@ To relate the ``Category`` and ``Product`` entities, start by creating a
826826
827827
// ...
828828
use Doctrine\Common\Collections\ArrayCollection;
829-
829+
830830
class Category
831831
{
832832
// ...
833-
833+
834834
/**
835835
* @ORM\OneToMany(targetEntity="Product", mappedBy="category")
836836
*/
837837
protected $products;
838-
838+
839839
public function __construct()
840840
{
841841
$this->products = new ArrayCollection();
@@ -872,7 +872,7 @@ makes sense in the application for each ``Category`` to hold an array of
872872
.. tip::
873873

874874
The targetEntity value in the decorator used above can reference any entity
875-
with a valid namespace, not just entities defined in the same class. To
875+
with a valid namespace, not just entities defined in the same class. To
876876
relate to an entity defined in a different class or bundle, enter a full
877877
namespace as the targetEntity.
878878

@@ -886,11 +886,11 @@ object, you'll want to add a ``$category`` property to the ``Product`` class:
886886
// src/Acme/StoreBundle/Entity/Product.php
887887
888888
// ...
889-
889+
890890
class Product
891891
{
892892
// ...
893-
893+
894894
/**
895895
* @ORM\ManyToOne(targetEntity="Category", inversedBy="products")
896896
* @ORM\JoinColumn(name="category_id", referencedColumnName="id")
@@ -972,18 +972,18 @@ Now, let's see the code in action. Imagine you're inside a controller::
972972
{
973973
$category = new Category();
974974
$category->setName('Main Products');
975-
975+
976976
$product = new Product();
977977
$product->setName('Foo');
978978
$product->setPrice(19.99);
979979
// relate this product to the category
980980
$product->setCategory($category);
981-
981+
982982
$em = $this->getDoctrine()->getManager();
983983
$em->persist($category);
984984
$em->persist($product);
985985
$em->flush();
986-
986+
987987
return new Response(
988988
'Created product id: '.$product->getId().' and category id: '.$category->getId()
989989
);
@@ -1009,7 +1009,7 @@ did before. First, fetch a ``$product`` object and then access its related
10091009
->find($id);
10101010

10111011
$categoryName = $product->getCategory()->getName();
1012-
1012+
10131013
// ...
10141014
}
10151015

@@ -1036,7 +1036,7 @@ You can also query in the other direction::
10361036
->find($id);
10371037

10381038
$products = $category->getProducts();
1039-
1039+
10401040
// ...
10411041
}
10421042

@@ -1051,7 +1051,7 @@ to the given ``Category`` object via their ``category_id`` value.
10511051
This "lazy loading" is possible because, when necessary, Doctrine returns
10521052
a "proxy" object in place of the true object. Look again at the above
10531053
example::
1054-
1054+
10551055
$product = $this->getDoctrine()
10561056
->getRepository('AcmeStoreBundle:Product')
10571057
->find($id);
@@ -1117,9 +1117,9 @@ object and its related ``Category`` with just one query::
11171117
->findOneByIdJoinedToCategory($id);
11181118

11191119
$category = $product->getCategory();
1120-
1120+
11211121
// ...
1122-
}
1122+
}
11231123

11241124
More Information on Associations
11251125
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -1235,7 +1235,7 @@ in general, see Doctrine's `Lifecycle Events documentation`_
12351235
callbacks should be simple methods that are concerned with internally
12361236
transforming data in the entity (e.g. setting a created/updated field,
12371237
generating a slug value).
1238-
1238+
12391239
If you need to do some heavier lifting - like perform logging or send
12401240
an email - you should register an external class as an event listener
12411241
or subscriber and give it access to whatever resources you need. For
@@ -1302,11 +1302,11 @@ and ``nullable``. Take a few examples:
13021302
/**
13031303
* A string field with length 255 that cannot be null
13041304
* (reflecting the default values for the "type", "length" and *nullable* options)
1305-
*
1305+
*
13061306
* @ORM\Column()
13071307
*/
13081308
protected $name;
1309-
1309+
13101310
/**
13111311
* A string field of length 150 that persists to an "email_address" column
13121312
* and has a unique index.
@@ -1366,9 +1366,9 @@ Some notable or interesting tasks include:
13661366
* ``doctrine:ensure-production-settings`` - checks to see if the current
13671367
environment is configured efficiently for production. This should always
13681368
be run in the ``prod`` environment:
1369-
1369+
13701370
.. code-block:: bash
1371-
1371+
13721372
$ php app/console doctrine:ensure-production-settings --env=prod
13731373
13741374
* ``doctrine:mapping:import`` - allows Doctrine to introspect an existing

book/routing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ routing system can be:
755755
756756
As you've seen, this route will only match if the ``{culture}`` portion of
757757
the URL is either ``en`` or ``fr`` and if the ``{year}`` is a number. This
758-
route also shows how you can use a period between placeholders instead of
758+
route also shows how you can use a dot between placeholders instead of
759759
a slash. URLs matching this route might look like:
760760

761761
* ``/articles/en/2010/my-post``

components/config/caching.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ the cache can tell if it is still fresh or that its contents should be regenerat
2727

2828
$cachePath = __DIR__.'/cache/appUserMatcher.php';
2929

30-
// the second argument indicates whether or not we are in debug mode
30+
// the second argument indicates whether or not you want to use debug mode
3131
$userMatcherCache = new ConfigCache($cachePath, true);
3232

3333
if (!$userMatcherCache->isFresh()) {

components/dependency_injection/introduction.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Then you can set the choice of transport in the container:
7777
$container->register('mailer', 'Mailer')
7878
->addArgument('sendmail');
7979
80-
This class is now much more flexible as we have separated the choice of
80+
This class is now much more flexible as you have separated the choice of
8181
transport out of the implementation and into the container.
8282

8383
Which mail transport you have chosen may be something other services need to
@@ -185,9 +185,9 @@ Avoiding Your Code Becoming Dependent on the Container
185185
------------------------------------------------------
186186

187187
Whilst you can retrieve services from the container directly it is best
188-
to minimize this. For example, in the ``NewsletterManager`` we injected
188+
to minimize this. For example, in the ``NewsletterManager`` you injected
189189
the ``mailer`` service in rather than asking for it from the container.
190-
We could have injected the container in and retrieved the ``mailer`` service
190+
You could have injected the container in and retrieved the ``mailer`` service
191191
from it but it would then be tied to this particular container making it
192192
difficult to reuse the class elsewhere.
193193

components/dependency_injection/parentservices.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ a parent for a service.
248248
$container->setDefinition('my_email_formatter', ...);
249249
$container->setDefinition('mail_manager', new Definition(
250250
'%mail_manager.class%'
251-
))->SetAbstract(
251+
))->setAbstract(
252252
true
253253
)->addMethodCall('setMailer', array(
254254
new Reference('my_mailer')
@@ -384,7 +384,7 @@ to the ``NewsletterManager`` class, the config would look like this:
384384
$container->setDefinition('my_email_formatter', ...);
385385
$container->setDefinition('mail_manager', new Definition(
386386
'%mail_manager.class%'
387-
))->SetAbstract(
387+
))->setAbstract(
388388
true
389389
)->addMethodCall('setMailer', array(
390390
new Reference('my_mailer')
@@ -501,7 +501,7 @@ If you had the following config:
501501
$container->setDefinition('another_filter', ...);
502502
$container->setDefinition('mail_manager', new Definition(
503503
'%mail_manager.class%'
504-
))->SetAbstract(
504+
))->setAbstract(
505505
true
506506
)->addMethodCall('setFilter', array(
507507
new Reference('my_filter')

components/dependency_injection/tags.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ Then, define the chain as a service:
6767
Define Services with a Custom Tag
6868
---------------------------------
6969

70-
Now we want several of the ``\Swift_Transport`` classes to be instantiated
70+
Now you might want several of the ``\Swift_Transport`` classes to be instantiated
7171
and added to the chain automatically using the ``addTransport()`` method.
72-
As an example we add the following transports as services:
72+
For example you may add the following transports as services:
7373

7474
.. configuration-block::
7575

@@ -206,7 +206,7 @@ To begin with, change the ``TransportChain`` class::
206206
}
207207

208208
As you can see, when ``addTransport`` is called, it takes not only a ``Swift_Transport``
209-
object, but also a string alias for that transport. So, how can we allow
209+
object, but also a string alias for that transport. So, how can you allow
210210
each tagged transport service to also supply an alias?
211211

212212
To answer this, change the service declaration:

0 commit comments

Comments
 (0)