mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
sf4 deprecated: migrate Doctrine ORM mapping to annotation
This commit is contained in:
parent
a38208f5cf
commit
3a03d44e9a
@ -21,60 +21,88 @@
|
||||
|
||||
namespace Chill\CustomFieldsBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* CustomField
|
||||
*
|
||||
* @ORM\Entity()
|
||||
* @ORM\Table(null)
|
||||
* @ORM\HasLifecycleCallbacks()
|
||||
*/
|
||||
class CustomField
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="string", length=255)
|
||||
*/
|
||||
private $slug;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="string", length=255)
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
*
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
private $active = true;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var array
|
||||
*
|
||||
* @ORM\Column(type="json_array")
|
||||
*/
|
||||
private $options = array();
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*
|
||||
* @ORM\Column(type="json_array")
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*
|
||||
* @ORM\Column(type="float")
|
||||
*/
|
||||
private $ordering;
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
*
|
||||
* @var bolean
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
private $required = FALSE;
|
||||
|
||||
|
||||
const ONE_TO_ONE = 1;
|
||||
const ONE_TO_MANY = 2;
|
||||
|
||||
/**
|
||||
* @var CustomFieldsGroup
|
||||
*
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="Chill\CustomFieldsBundle\Entity\CustomFieldsGroup",
|
||||
* inversedBy="customFields")
|
||||
*/
|
||||
private $customFieldGroup;
|
||||
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
@ -85,22 +113,26 @@ class CustomField
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function getSlug()
|
||||
{
|
||||
return $this->slug;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
function getOptions()
|
||||
{
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Set type
|
||||
*
|
||||
* @param string $type
|
||||
*
|
||||
* @return CustomField
|
||||
*/
|
||||
public function setType($type)
|
||||
@ -125,7 +157,6 @@ class CustomField
|
||||
* Set active
|
||||
*
|
||||
* @param boolean $active
|
||||
*
|
||||
* @return CustomField
|
||||
*/
|
||||
public function setActive($active)
|
||||
@ -158,11 +189,10 @@ class CustomField
|
||||
/**
|
||||
* Set customFieldGroup
|
||||
*
|
||||
* @param \Chill\CustomFieldsBundle\Entity\CustomFieldsGroup $customFieldGroup
|
||||
*
|
||||
* @param CustomFieldsGroup $customFieldGroup
|
||||
* @return CustomField
|
||||
*/
|
||||
public function setCustomFieldsGroup(\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup $customFieldGroup = null)
|
||||
public function setCustomFieldsGroup(CustomFieldsGroup $customFieldGroup = null)
|
||||
{
|
||||
$this->customFieldGroup = $customFieldGroup;
|
||||
|
||||
@ -173,7 +203,6 @@ class CustomField
|
||||
* Set name
|
||||
*
|
||||
* @param array $name
|
||||
*
|
||||
* @return CustomField
|
||||
*/
|
||||
public function setName($name)
|
||||
@ -212,7 +241,6 @@ class CustomField
|
||||
* Set order
|
||||
*
|
||||
* @param float $order
|
||||
*
|
||||
* @return CustomField
|
||||
*/
|
||||
public function setOrdering($order)
|
||||
@ -236,7 +264,6 @@ class CustomField
|
||||
* Set options
|
||||
*
|
||||
* @param array $options
|
||||
*
|
||||
* @return CustomField
|
||||
*/
|
||||
public function setOptions(array $options)
|
||||
@ -245,8 +272,11 @@ class CustomField
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $slug
|
||||
* @return $this
|
||||
*/
|
||||
public function setSlug($slug)
|
||||
{
|
||||
$this->slug = $slug;
|
||||
@ -278,8 +308,5 @@ class CustomField
|
||||
$this->required = $required;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -19,93 +19,134 @@
|
||||
|
||||
namespace Chill\CustomFieldsBundle\Entity\CustomFieldLongChoice;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
*
|
||||
* @ORM\Entity(
|
||||
* repositoryClass="Chill\CustomFieldsBundle\EntityRepository\CustomFieldLongChoice\OptionRepository")
|
||||
* @ORM\Table(name="custom_field_long_choice_options")
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
class Option
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
*
|
||||
* @var int
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
* @ORM\Column(type="string", length=15)
|
||||
*/
|
||||
private $key;
|
||||
|
||||
/**
|
||||
* a json representation of text (multilingual)
|
||||
* A json representation of text (multilingual)
|
||||
*
|
||||
* @var array
|
||||
* @ORM\Column(type="text")
|
||||
*/
|
||||
private $text;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var \Doctrine\Common\Collections\Collection
|
||||
* @var Collection
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity="Chill\CustomFieldsBundle\Entity\CustomFieldLongChoice\Option",
|
||||
* mappedBy="parent")
|
||||
*/
|
||||
private $children;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Option
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="Chill\CustomFieldsBundle\Entity\CustomFieldLongChoice\Option",
|
||||
* inversedBy="children")
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*/
|
||||
private $parent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
* @ORM\Column(type="string", length=50, name="internal_key")
|
||||
*/
|
||||
private $internalKey = '';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var boolean
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
private $active = true;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getKey()
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getText()
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getChildren()
|
||||
{
|
||||
return $this->children;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Option
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $key
|
||||
* @return $this
|
||||
*/
|
||||
public function setKey($key)
|
||||
{
|
||||
$this->key = $key;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $text
|
||||
* @return $this
|
||||
*/
|
||||
public function setText(array $text)
|
||||
{
|
||||
$this->text = $text;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Option|null $parent
|
||||
* @return $this
|
||||
*/
|
||||
public function setParent(Option $parent = null)
|
||||
{
|
||||
$this->parent = $parent;
|
||||
@ -122,32 +163,48 @@ class Option
|
||||
return $this->parent === NULL ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getInternalKey()
|
||||
{
|
||||
return $this->internalKey;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isActive()
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getActive()
|
||||
{
|
||||
return $this->isActive();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $internal_key
|
||||
* @return $this
|
||||
*/
|
||||
public function setInternalKey($internal_key)
|
||||
{
|
||||
$this->internalKey = $internal_key;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $active
|
||||
* @return $this
|
||||
*/
|
||||
public function setActive($active)
|
||||
{
|
||||
$this->active = $active;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -21,23 +21,44 @@
|
||||
|
||||
namespace Chill\CustomFieldsBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* CustomFieldsDefaultGroup
|
||||
*
|
||||
* @ORM\Entity()
|
||||
* @ORM\Table(
|
||||
* null,
|
||||
* uniqueConstraints={@ORM\UniqueConstraint(
|
||||
* name="unique_entity",
|
||||
* columns={"entity"}
|
||||
* )})
|
||||
*/
|
||||
class CustomFieldsDefaultGroup
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="string", length=255)
|
||||
*/
|
||||
private $entity;
|
||||
|
||||
/**
|
||||
* @var CustomFieldsGroup
|
||||
*
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="Chill\CustomFieldsBundle\Entity\CustomFieldsGroup")
|
||||
*
|
||||
* sf4 check: option inversedBy="customFields" return inconsistent error mapping !!
|
||||
*/
|
||||
private $customFieldsGroup;
|
||||
|
||||
@ -55,7 +76,6 @@ class CustomFieldsDefaultGroup
|
||||
* Set entity
|
||||
*
|
||||
* @param string $entity
|
||||
*
|
||||
* @return CustomFieldsDefaultGroup
|
||||
*/
|
||||
public function setEntity($entity)
|
||||
@ -78,8 +98,7 @@ class CustomFieldsDefaultGroup
|
||||
/**
|
||||
* Set customFieldsGroup
|
||||
*
|
||||
* @param CustomFieldsGroup $customFieldsGroup
|
||||
*
|
||||
* @param CustomFieldsGroup $customFieldsGroup *
|
||||
* @return CustomFieldsDefaultGroup
|
||||
*/
|
||||
public function setCustomFieldsGroup($customFieldsGroup)
|
||||
|
@ -21,64 +21,85 @@
|
||||
|
||||
namespace Chill\CustomFieldsBundle\Entity;
|
||||
|
||||
use \Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
||||
/**
|
||||
* CustomFieldGroup
|
||||
*
|
||||
* @ORM\Entity()
|
||||
* @ORM\Table(null)
|
||||
*/
|
||||
class CustomFieldsGroup
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*
|
||||
* @ORM\Column(type="json_array")
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="string", length=255)
|
||||
*/
|
||||
private $entity;
|
||||
|
||||
/**
|
||||
* @var \Doctrine\Common\Collections\Collection $customFields: The custom
|
||||
* fields of the group. The custom fields are asc-ordered regarding to their
|
||||
* property "ordering".
|
||||
* The custom fields of the group.
|
||||
* The custom fields are asc-ordered regarding to their property "ordering".
|
||||
*
|
||||
* @var Collection $customFields
|
||||
*
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity="Chill\CustomFieldsBundle\Entity\CustomField",
|
||||
* mappedBy="customFieldGroup")
|
||||
* @ORM\OrderBy({"ordering" = "ASC"})
|
||||
*/
|
||||
private $customFields;
|
||||
|
||||
/**
|
||||
* @var array(customField) | null $activeCustomFields: The custom fields
|
||||
* of the group that are active. This variable if null, if this
|
||||
* informations has not been computed.
|
||||
* The custom fields of the group that are active.
|
||||
* This variable if null, if this informations has not been computed.
|
||||
*
|
||||
* @var array|null
|
||||
*/
|
||||
private $activeCustomFields = null;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var array
|
||||
*
|
||||
* @ORM\Column(type="json_array")
|
||||
*/
|
||||
private $options = array();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* CustomFieldsGroup constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->customFields = new \Doctrine\Common\Collections\ArrayCollection();
|
||||
$this->customFields = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add customField
|
||||
*
|
||||
* @param \Chill\CustomFieldsBundle\Entity\CustomField $customField
|
||||
*
|
||||
* @param CustomField $customField
|
||||
* @return CustomFieldsGroup
|
||||
*/
|
||||
public function addCustomField(\Chill\CustomFieldsBundle\Entity\CustomField $customField)
|
||||
public function addCustomField(CustomField $customField)
|
||||
{
|
||||
$this->customFields[] = $customField;
|
||||
|
||||
@ -88,16 +109,15 @@ class CustomFieldsGroup
|
||||
/**
|
||||
* Remove customField
|
||||
*
|
||||
* @param \Chill\CustomFieldsBundle\Entity\CustomField $customField
|
||||
* @param CustomField $customField
|
||||
*/
|
||||
public function removeCustomField(\Chill\CustomFieldsBundle\Entity\CustomField $customField)
|
||||
public function removeCustomField(CustomField $customField)
|
||||
{
|
||||
$this->customFields->removeElement($customField);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return \Doctrine\Common\Collections\Collection
|
||||
* @return Collection
|
||||
*/
|
||||
public function getCustomFields()
|
||||
{
|
||||
@ -107,7 +127,7 @@ class CustomFieldsGroup
|
||||
/**
|
||||
* Get all the custom
|
||||
*
|
||||
* @return \Doctrine\Common\Collections\Collection
|
||||
* @return Collection
|
||||
*/
|
||||
public function getActiveCustomFields()
|
||||
{
|
||||
@ -122,7 +142,6 @@ class CustomFieldsGroup
|
||||
|
||||
return $this->activeCustomFields;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get id
|
||||
@ -138,7 +157,6 @@ class CustomFieldsGroup
|
||||
* Set name
|
||||
*
|
||||
* @param array $name
|
||||
*
|
||||
* @return CustomFieldsGroup
|
||||
*/
|
||||
public function setName($name)
|
||||
@ -178,7 +196,6 @@ class CustomFieldsGroup
|
||||
* Set entity
|
||||
*
|
||||
* @param string $entity
|
||||
*
|
||||
* @return CustomFieldsGroup
|
||||
*/
|
||||
public function setEntity($entity)
|
||||
@ -212,7 +229,7 @@ class CustomFieldsGroup
|
||||
* set options array
|
||||
*
|
||||
* @param array $options
|
||||
* @return \Chill\CustomFieldsBundle\Entity\CustomFieldsGroup
|
||||
* @return CustomFieldsGroup
|
||||
*/
|
||||
public function setOptions(array $options)
|
||||
{
|
||||
|
@ -1,32 +0,0 @@
|
||||
Chill\CustomFieldsBundle\Entity\CustomField:
|
||||
type: entity
|
||||
table: null
|
||||
id:
|
||||
id:
|
||||
type: integer
|
||||
id: true
|
||||
generator:
|
||||
strategy: AUTO
|
||||
fields:
|
||||
name:
|
||||
type: json_array
|
||||
slug:
|
||||
type: string
|
||||
length: 255
|
||||
type:
|
||||
type: string
|
||||
length: 255
|
||||
active:
|
||||
type: boolean
|
||||
ordering:
|
||||
type: float
|
||||
options:
|
||||
type: json_array
|
||||
required:
|
||||
type: boolean
|
||||
lifecycleCallbacks: { }
|
||||
manyToOne:
|
||||
customFieldGroup:
|
||||
targetEntity: Chill\CustomFieldsBundle\Entity\CustomFieldsGroup
|
||||
inversedBy: customFields
|
||||
#TODO: add an unique constraint slug+customFieldsGroup
|
@ -1,33 +0,0 @@
|
||||
Chill\CustomFieldsBundle\Entity\CustomFieldLongChoice\Option:
|
||||
type: entity
|
||||
table: custom_field_long_choice_options
|
||||
repositoryClass: Chill\CustomFieldsBundle\EntityRepository\CustomFieldLongChoice\OptionRepository
|
||||
id:
|
||||
id:
|
||||
type: integer
|
||||
id: true
|
||||
generator:
|
||||
strategy: AUTO
|
||||
fields:
|
||||
key:
|
||||
type: string
|
||||
length: 15
|
||||
text:
|
||||
type: json_array
|
||||
internalKey:
|
||||
type: string
|
||||
length: 50
|
||||
column: internal_key
|
||||
active:
|
||||
type: boolean
|
||||
default: true
|
||||
oneToMany:
|
||||
children:
|
||||
targetEntity: Chill\CustomFieldsBundle\Entity\CustomFieldLongChoice\Option
|
||||
mappedBy: parent
|
||||
manyToOne:
|
||||
parent:
|
||||
targetEntity: Chill\CustomFieldsBundle\Entity\CustomFieldLongChoice\Option
|
||||
inversedBy: children
|
||||
nullable: true
|
||||
|
@ -1,20 +0,0 @@
|
||||
Chill\CustomFieldsBundle\Entity\CustomFieldsDefaultGroup:
|
||||
type: entity
|
||||
table: null
|
||||
id:
|
||||
id:
|
||||
type: integer
|
||||
id: true
|
||||
generator:
|
||||
strategy: AUTO
|
||||
fields:
|
||||
entity:
|
||||
type: string
|
||||
length: 255
|
||||
manyToOne:
|
||||
customFieldsGroup:
|
||||
targetEntity: Chill\CustomFieldsBundle\Entity\CustomFieldsGroup
|
||||
inversedBy: customFields
|
||||
uniqueConstraints:
|
||||
unique_entity:
|
||||
columns: [ entity ]
|
@ -1,22 +0,0 @@
|
||||
Chill\CustomFieldsBundle\Entity\CustomFieldsGroup:
|
||||
type: entity
|
||||
table: null
|
||||
id:
|
||||
id:
|
||||
type: integer
|
||||
id: true
|
||||
generator:
|
||||
strategy: AUTO
|
||||
fields:
|
||||
name:
|
||||
type: json_array
|
||||
entity:
|
||||
type: string
|
||||
length: 255
|
||||
options:
|
||||
type: json_array
|
||||
oneToMany:
|
||||
customFields:
|
||||
orderBy: { 'ordering': 'ASC' }
|
||||
targetEntity: Chill\CustomFieldsBundle\Entity\CustomField
|
||||
mappedBy: customFieldGroup
|
Loading…
x
Reference in New Issue
Block a user