Skip to content

Commit

Permalink
[Docs] Add entity documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
NoUseFreak committed Mar 19, 2015
1 parent c15a26f commit 34899ee
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 7 deletions.
76 changes: 76 additions & 0 deletions docs/entities.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
========
Entities
========

.. _overview:

Overview
========

Clastic uses doctrine to handle all data. It also give you an `Node` approach.
Nodes are entities that have basic information.

- title (string)
- user (User)
- create (DateTime)
- changed (DateTime)
- publication (NodePublication)
- available (boolean)
- publishedFrom (DateTime)
- publishedTill (DateTime)

.. _create_node:

Create
======

You can use whatever approach you want to generate the base entity. The simplest way is to use
the doctrine generator.

.. code-block:: bash
php app/console doctrine:generate:entity
Fill in all the field you need.

.. note::

You don't need to define fields like title, author, ... when you choose to make them Nodes.

Once you created your entity you need to alter the generated code.

Object
~~~~~~

Change the `NodeReferenceInterface` to your freshly generator entity. You can also use the
`NodeReferenceTrait` which helps you implement the interface.

ex:

.. code-block:: php
<?php
namespace Clastic\BlogBundle\Entity;
use Clastic\NodeBundle\Entity\Node;
use Clastic\NodeBundle\Node\NodeReferenceInterface;
class Blog implements NodeReferenceInterface
{
use NodeReferenceTrait;
// ...
}
Definition
~~~~~~~~~~

Add the following code to your xml definition.

.. code-block:: xml
<many-to-one field="node" target-entity="Clastic\NodeBundle\Entity\Node">
<cascade><cascade-all/></cascade>
<join-column name="node_id" referenced-column-name="id" />
</many-to-one>
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ User guide
:maxdepth: 2

overview
entities
modules

9 changes: 2 additions & 7 deletions docs/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,12 @@ Clastic uses modules to expose data to the backend.

To generate a module you must first create an entity.

.. code-block:: bash
php app/console doctrine:generate:entity
Fill in all the field you need.
See :doc:`entities` for more information on the entities.

.. note::

You don't need to define fields like title, author, ... when you choose to make them Nodes.
The generator only supports Node modules at the moment.

Once you created your entity you can generate your module.

.. code-block:: bash
Expand Down

0 comments on commit 34899ee

Please sign in to comment.