Annotations Reference ===================== In this chapter a reference of every PHPCR-ODM annotation is given with short explanations on their context and usage. Note on usage ------------- Note that the code examples are given without their namespaces, however it is normally necessary to import the annotation namespace into your class, and to prefix each annotation with the namespace as demonstrated in the following example: .. code-block:: php ` - **mixins**: Optional list of PHPCR mixins that will be added to the node on creation. Minimal example: .. code-block:: php `. Optional attributes: - **nodeType**: PHPCR type for this node. Default ``nt:unstructured``. - **repositoryClass**: Fully qualified name of the repository to use for documents extending this superclass. - **translator**: Determines how translations are stored, one of ``attribute`` or ``child``. See :ref:`language mapping `. .. code-block:: php `. - **translated**: ``true`` to specify that the property should be translatable, requires the ``translator`` attribute to be specified in :ref:`@Document`. - **nullable**: ``true`` to specifiy that this property doesn't have a required value, used when loading a translation, to allow loading a node with a missing translated property. Examples: .. code-block:: php 0.810709, 'EUR' => 1, 'USD' => 1.307460) .. _annref_binary: @Binary ~~~~~~~ Sets the type of the annotated instance variable to binary. Attributes: - Inherits :ref:`value field attributes `. .. _annref_boolean: @Boolean ~~~~~~~~ Sets the type of the annotated instance variable to boolean. Attributes: - Inherits :ref:`value field attributes `. .. _annref_date: @Date ~~~~~ Sets the type of the annotated instance variable to DateTime. Attributes: - Inherits :ref:`value field attributes `. .. _annref_decimal: @Decimal ~~~~~~~~ Sets the type of the annotated instance variable to decimal. The decimal field uses the BCMath library which supports numbers of any size or precision. Attributes: - Inherits :ref:`value field attributes `. .. _annref_double: @Double ~~~~~~~ Sets the type of the annotated instance variable to double. The PHP type will be **float**. Attributes: - Inherits :ref:`value field attributes `. .. _annref_long: @Long ~~~~~ Sets the type of the annotated instance variable to long. The PHP type will be **integer**. Attributes: - Inherits :ref:`value field attributes `. .. _annref_name: @Name ~~~~~ The annotated instance variable must be a valid XML CNAME value and can be used to store a valid node name. Attributes: - Inherits :ref:`value field attributes `. .. _annref_path: @Path ~~~~~ The annotated instance variable must be a valid PHPCR node path and can be used to store an arbitrary reference to another node. Attributes: - Inherits :ref:`value field attributes `. .. _annref_string: @String ~~~~~~~ Sets the type of the annotated instance variable to string. Attributes: - Inherits :ref:`value field attributes `. .. _annref_uri: @Uri ~~~~ The annotated instance variable will be validated as an URI. Attributes: - Inherits :ref:`value field attributes `. Hierarchy --------- These mappings mark the annotated instance variables to contain instances of Documents above or below the current Document in the document hierarchy. They need to be specified inside the instance variables associated PHP DocBlock comment. .. _annref_child: @Child ~~~~~~ The annotated instance variable will be populated with the named document directly below the instance variables document class in the document hierarchy. Required attributes: - **name**: Node name of the child document to map, this should be a string. .. code-block:: php `. Required attributes: - **strategy**: How to generate IDs, one of ``NONE``, ``REPOSITORY``, ``ASSIGNED`` or ``PARENT``, default is ``PARENT`` See :ref:`generation strategies `. .. code-block:: php `. Changing the marked variable will update the nodes ID. .. code-block:: php ` corresponding to the name of the annotation. .. note:: Unlike the Doctrine ORM it is **not** necessary to specify a ``@HasLifecycleCallbacks`` annotation. .. _annref_postload: @PostLoad ~~~~~~~~~ Life cycle callback. The marked method will be called automatically on the ``postLoad`` event. See :ref:`lifecycle callbacks ` .. code-block:: php ` .. code-block:: php ` .. code-block:: php ` .. code-block:: php ` .. code-block:: php ` .. code-block:: php ` .. code-block:: php `. References ---------- .. _annref_referencemany: @ReferenceMany ~~~~~~~~~~~~~~ Optional attributes: - **targetDocument**: Specify type of target document class. Note that this is an optional parameter and by default you can associate *any* document. - **strategy**: One of ``weak``, ``hard`` or ``path``. See :ref:`reference other documents `. .. code-block:: php `. .. code-block:: php `. Example: .. code-block:: php `. See :ref:`versioning mappings `. Example: .. code-block:: php