-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c15a26f
commit 34899ee
Showing
3 changed files
with
79 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,5 +15,6 @@ User guide | |
:maxdepth: 2 | ||
|
||
overview | ||
entities | ||
modules | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters