Skip to content

Commit

Permalink
Replace annotations mapping by YAML mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
webeweb committed Dec 20, 2017
1 parent 6a2f5f2 commit 98bc5dc
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 33 deletions.
33 changes: 0 additions & 33 deletions Entity/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@

use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Constraints\Collection;
use WBW\Library\Core\Form\Renderer\ChoiceRendererInterface;
use WBW\Library\Core\Sort\Tree\Alphabetical\AlphabeticalTreeSortInterface;
Expand All @@ -25,53 +23,34 @@
*
* @author NdC/WBW <https://github.com/webeweb/>
* @package WBW\Bundle\EDMBundle\Entity
* @ORM\Entity(repositoryClass="WBW\Bundle\EDMBundle\Repository\DocumentRepository")
* @ORM\Table(
* name="edm_document",
* options={"charset":"utf8", "collate":"utf8_general_ci"},
* indexes={
* @ORM\Index(name="document_idx_parent", columns={"parent_id"})
* }
* )
*/
class Document implements AlphabeticalTreeSortInterface, ChoiceRendererInterface, DocumentInterface {

/**
* Childrens.
*
* @var Collection
* @ORM\OneToMany(targetEntity="Document", mappedBy="parent")
*/
private $childrens;

/**
* Created at.
*
* @var DateTime
* @ORM\Column(name="created_at", type="datetime", nullable=false)
*/
private $createdAt;

/**
* Id.
*
* @var int
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;

/**
* Name.
*
* @var string
* @ORM\Column(name="name", type="string", length=45, nullable=false)
* @Assert\NotNull(message="document.name.notNull.message")
* @Assert\Length(
* max=45,
* maxMessage="document.name.length.maxMessage"
* )
*/
private $name;

Expand All @@ -93,39 +72,27 @@ class Document implements AlphabeticalTreeSortInterface, ChoiceRendererInterface
* Parent.
*
* @var Document
* @ORM\ManyToOne(targetEntity="Document", inversedBy="childrens")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
* })
*/
private $parent;

/**
* Size.
*
* @var integer
* @ORM\Column(name="size", type="integer", nullable=false)
* @Assert\NotNull(message="document.size.notNull.message")
* @Assert\Range(
* min=0,
* minMessage="document.size.range.minMessage"
* )
*/
private $size;

/**
* Type.
*
* @var integer
* @ORM\Column(name="type", type="integer", nullable=false, options={"default": 117})
*/
private $type = self::TYPE_DOCUMENT;

/**
* Updated at.
*
* @var DateTime
* @ORM\Column(name="updated_at", type="datetime", nullable=true)
*/
private $updatedAt;

Expand Down
57 changes: 57 additions & 0 deletions Resources/config/doctrine/Document.orm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Resources/doctrine/Document.orm.yml
WBW\Bundle\EDMBundle\Entity\Document:

type: entity
repositoryClass: WBW\Bundle\EDMBundle\Repository\DocumentRepository
table: edm_document

indexes:
document_idx_parent:
columns: [ parent_id ]

id:
id:
name: id
type: integer
generator: { strategy: auto }

fields:
createdAt:
column: created_at
type: datetime
nullable: false
name:
column: name
type: string
length: 255
nullable: false
size:
column: size
type: integer
nullable: false
options:
default: 0
type:
column: type
type: integer
nullable: false
options:
default: 117
updatedAt:
column: updated_at
type: datetime
nullable: false

oneToMany:
childrens:
targetEntity: WBW\Bundle\EDMBundle\Entity\Document
mappedBy: parent

manyToOne:
parent:
targetEntity: WBW\Bundle\EDMBundle\Entity\Document
inversedBy: childrens
joinColums:
joinColumn:
name: parent_id
referencedColumneName: id

0 comments on commit 98bc5dc

Please sign in to comment.