From b5827ea83fafe23d5109d44009387f8c11d334f1 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sun, 12 Jun 2011 23:07:21 +0200 Subject: [PATCH] Add tons of xml and yaml configuration blocks to basic- and association-mapping chapters --- en/reference/association-mapping.rst | 315 ++++++++++++++++++++------- en/reference/basic-mapping.rst | 281 ++++++++++++++++++------ 2 files changed, 449 insertions(+), 147 deletions(-) diff --git a/en/reference/association-mapping.rst b/en/reference/association-mapping.rst index a992c15b4..869fc1235 100644 --- a/en/reference/association-mapping.rst +++ b/en/reference/association-mapping.rst @@ -133,57 +133,151 @@ follows: As an example, consider this mapping: -.. code-block:: php +.. configuration-block:: - + + + + + + .. code-block:: yaml + + Product: + type: entity + oneToOne: + shipping: + targetEntity: Shipping This is essentially the same as the following, more verbose, mapping: -.. code-block:: php +.. configuration-block:: - + + + + + + + + .. code-block:: yaml + + Product: + type: entity + oneToOne: + shipping: + targetEntity: Shipping + joinColumn: + name: shipping_id + referencedColumnName: id The @JoinTable definition used for many-to-many mappings has similar defaults. As an example, consider this mapping: -.. code-block:: php +.. code-configuration:: - + + + + + + .. code-block:: yaml + + User: + type: entity + manyToMany: + groups: + targetEntity: Group This is essentially the same as the following, more verbose, mapping: -.. code-block:: php +.. configuration-block:: - + + + + + + + + + + + + + + + .. code-block:: yaml + + User: + type: entity + manyToMany: + groups: + targetEntity: Group + joinTable: + name: User_Group + joinColumns: + User_id: + referencedColumnName: id + inverseJoinColumns: + Group_id + referencedColumnName: id In that case, the name of the join table defaults to a combination of the simple, unqualified class names of the participating @@ -276,6 +370,7 @@ Or you can trigger the validation manually: .. code-block:: php + + + + + + + + + .. code-block:: yaml + + Product: + type: entity + oneToOne: + shipping: + targetEntity: Shipping + joinColumn: + name: shipping_id + referencedColumnName: id Note that the @JoinColumn is not really necessary in this example, as the defaults would be the same. @@ -354,35 +472,66 @@ Here is a one-to-one relationship between a ``Customer`` and a ``Cart``. The ``Cart`` has a reference back to the ``Customer`` so it is bidirectional. -.. code-block:: php +.. configuration-block:: - + + + + + + + + + + + .. code-block:: yaml + + Customer: + oneToOne: + cart: + targetEntity: Cart + mappedBy: customer + Cart: + oneToOne: + customer: + targetEntity Customer + inversedBy: cart + joinColumn: + customer_id: + referencedColumnName: id Note that the @JoinColumn is not really necessary in this example, as the defaults would be the same. diff --git a/en/reference/basic-mapping.rst b/en/reference/basic-mapping.rst index 970782279..0a00ee702 100644 --- a/en/reference/basic-mapping.rst +++ b/en/reference/basic-mapping.rst @@ -16,9 +16,11 @@ object-relational mapping metadata: - XML - YAML -This manual usually uses docblock annotations in all the examples -that are spread throughout all chapters. There are dedicated -chapters for XML and YAML mapping, respectively. +This manual usually mentions docblock annotations in all the examples +that are spread throughout all chapters, however for many examples +alternative YAML and XML examples are given aswell. There are dedicated +reference chapters for XML and YAML mapping, respectively that explain them +in more detail. There is also an Annotation reference chapter. .. note:: @@ -56,7 +58,9 @@ annotations support namespaces and nested annotations among other things. The Doctrine 2 ORM defines its own set of docblock annotations for supplying object-relational mapping metadata. - **NOTE** If you're not comfortable with the concept of docblock +.. note:: + + If you're not comfortable with the concept of docblock annotations, don't worry, as mentioned earlier Doctrine 2 provides XML and YAML alternatives and you could easily implement your own favourite mechanism for defining ORM metadata. @@ -69,30 +73,63 @@ In order to mark a class for object-relational persistence it needs to be designated as an entity. This can be done through the ``@Entity`` marker annotation. -.. code-block:: php +.. configuration-block:: - + +