sf4 deprecated: migrate Doctrine ORM mapping to annotation

This commit is contained in:
Tchama 2020-07-24 20:20:07 +02:00
parent c69d6d6bb8
commit 6ccfa8a130
8 changed files with 101 additions and 123 deletions

View File

@ -20,82 +20,105 @@
namespace Chill\ActivityBundle\Entity; namespace Chill\ActivityBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Entity\Center;
use Chill\ActivityBundle\Entity\ActivityReason; use Chill\ActivityBundle\Entity\ActivityReason;
use Chill\ActivityBundle\Entity\ActivityType; use Chill\ActivityBundle\Entity\ActivityType;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;
use Chill\MainBundle\Entity\HasCenterInterface; use Chill\MainBundle\Entity\HasCenterInterface;
use Chill\MainBundle\Entity\HasScopeInterface; use Chill\MainBundle\Entity\HasScopeInterface;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Chill\MainBundle\Validator\Constraints\Entity\UserCircleConsistency; use Chill\MainBundle\Validator\Constraints\Entity\UserCircleConsistency;
/** /**
* Activity * Class Activity
* @UserCircleConsistency( *
* "CHILL_ACTIVITY_SEE_DETAILS", * @package Chill\ActivityBundle\Entity
* getUserFunction="getUser", * @ORM\Entity()
* path="scope" * @ORM\Table(null)
* ) * @ORM\HasLifecycleCallbacks()
* @UserCircleConsistency(
* "CHILL_ACTIVITY_SEE_DETAILS",
* getUserFunction="getUser",
* path="scope")
*/ */
class Activity implements HasCenterInterface, HasScopeInterface class Activity implements HasCenterInterface, HasScopeInterface
{ {
/** /**
* @var integer * @var integer
*
* @ORM\Id
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/ */
private $id; private $id;
/** /**
* @var User * @var User
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
*/ */
private $user; private $user;
/** /**
* @var \DateTime * @var \DateTime
* @ORM\Column(type="datetime")
*/ */
private $date; private $date;
/** /**
* @var \DateTime * @var \DateTime
* @ORM\Column(type="time")
*/ */
private $durationTime; private $durationTime;
/** /**
* @var string * @var string
* @ORM\Column(type="text")
*/ */
private $remark; private $remark;
/** /**
* @var boolean * @var boolean
* @ORM\Column(type="boolean")
*/ */
private $attendee; private $attendee;
/** /**
* @var \Doctrine\Common\Collections\Collection * @var ActivityReason
* @ORM\ManyToMany(targetEntity="Chill\ActivityBundle\Entity\ActivityReason")
*/ */
private $reasons; private $reasons;
/** /**
* @var ActivityType * @var ActivityType
* @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityType")
*/ */
private $type; private $type;
/** /**
* @var Scope * @var Scope
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Scope")
*/ */
private $scope; private $scope;
/** /**
* @var Person * @var Person
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\Person")
*/ */
private $person; private $person;
/**
* Activity constructor.
*/
public function __construct() public function __construct()
{ {
$this->reasons = new ArrayCollection(); $this->reasons = new ArrayCollection();
} }
/** /**
* Get id * Get id
* *
@ -110,7 +133,6 @@ class Activity implements HasCenterInterface, HasScopeInterface
* Set user * Set user
* *
* @param User $user * @param User $user
*
* @return Activity * @return Activity
*/ */
public function setUser(User $user) public function setUser(User $user)
@ -134,7 +156,6 @@ class Activity implements HasCenterInterface, HasScopeInterface
* Set date * Set date
* *
* @param \DateTime $date * @param \DateTime $date
*
* @return Activity * @return Activity
*/ */
public function setDate($date) public function setDate($date)
@ -158,7 +179,6 @@ class Activity implements HasCenterInterface, HasScopeInterface
* Set durationTime * Set durationTime
* *
* @param \DateTime $durationTime * @param \DateTime $durationTime
*
* @return Activity * @return Activity
*/ */
public function setDurationTime($durationTime) public function setDurationTime($durationTime)
@ -182,7 +202,6 @@ class Activity implements HasCenterInterface, HasScopeInterface
* Set remark * Set remark
* *
* @param string $remark * @param string $remark
*
* @return Activity * @return Activity
*/ */
public function setRemark($remark) public function setRemark($remark)
@ -206,7 +225,6 @@ class Activity implements HasCenterInterface, HasScopeInterface
* Set attendee * Set attendee
* *
* @param boolean $attendee * @param boolean $attendee
*
* @return Activity * @return Activity
*/ */
public function setAttendee($attendee) public function setAttendee($attendee)
@ -230,7 +248,6 @@ class Activity implements HasCenterInterface, HasScopeInterface
* Add a reason * Add a reason
* *
* @param ActivityReason $reason * @param ActivityReason $reason
*
* @return Activity * @return Activity
*/ */
public function addReason(ActivityReason $reason) public function addReason(ActivityReason $reason)
@ -240,6 +257,9 @@ class Activity implements HasCenterInterface, HasScopeInterface
return $this; return $this;
} }
/**
* @param ActivityReason $reason
*/
public function removeReason(ActivityReason $reason) public function removeReason(ActivityReason $reason)
{ {
$this->reasons->removeElement($reason); $this->reasons->removeElement($reason);
@ -248,7 +268,7 @@ class Activity implements HasCenterInterface, HasScopeInterface
/** /**
* Get reasons * Get reasons
* *
* @return \Doctrine\Common\Collections\Collection * @return Collection
*/ */
public function getReasons() public function getReasons()
{ {
@ -259,7 +279,6 @@ class Activity implements HasCenterInterface, HasScopeInterface
* Set type * Set type
* *
* @param ActivityType $type * @param ActivityType $type
*
* @return Activity * @return Activity
*/ */
public function setType(ActivityType $type) public function setType(ActivityType $type)
@ -283,7 +302,6 @@ class Activity implements HasCenterInterface, HasScopeInterface
* Set scope * Set scope
* *
* @param Scope $scope * @param Scope $scope
*
* @return Activity * @return Activity
*/ */
public function setScope(Scope $scope) public function setScope(Scope $scope)
@ -307,7 +325,6 @@ class Activity implements HasCenterInterface, HasScopeInterface
* Set person * Set person
* *
* @param Person $person * @param Person $person
*
* @return Activity * @return Activity
*/ */
public function setPerson(Person $person) public function setPerson(Person $person)
@ -329,10 +346,9 @@ class Activity implements HasCenterInterface, HasScopeInterface
/** /**
* get the center * get the center
*
* center is extracted from person * center is extracted from person
* *
* @return \Chill\MainBundle\Entity\Center * @return Center
*/ */
public function getCenter() public function getCenter()
{ {

View File

@ -20,30 +20,45 @@
namespace Chill\ActivityBundle\Entity; namespace Chill\ActivityBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Chill\ActivityBundle\Entity\ActivityReasonCategory; use Chill\ActivityBundle\Entity\ActivityReasonCategory;
/** /**
* ActivityReason * Class ActivityReason
*
* @package Chill\ActivityBundle\Entity
* @ORM\Entity()
* @ORM\Table(null)
* @ORM\HasLifecycleCallbacks()
*/ */
class ActivityReason class ActivityReason
{ {
/** /**
* @var integer * @var integer
*
* @ORM\Id
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/ */
private $id; private $id;
/** /**
* @var array * @var array
* @ORM\Column(type="json_array")
*/ */
private $name; private $name;
/** /**
* @var ActivityReasonCategory * @var ActivityReasonCategory
* @ORM\ManyToOne(
* targetEntity="Chill\ActivityBundle\Entity\ActivityReasonCategory",
* inversedBy="reasons")
*/ */
private $category; private $category;
/** /**
* @var boolean * @var boolean
* @ORM\Column(type="boolean")
*/ */
private $active = true; private $active = true;
@ -62,7 +77,6 @@ class ActivityReason
* Set name * Set name
* *
* @param array $name * @param array $name
*
* @return ActivityReason * @return ActivityReason
*/ */
public function setName($name) public function setName($name)
@ -100,7 +114,6 @@ class ActivityReason
* category, the reason will become inactive * category, the reason will become inactive
* *
* @param ActivityReasonCategory $category * @param ActivityReasonCategory $category
*
* @return ActivityReason * @return ActivityReason
*/ */
public function setCategory(ActivityReasonCategory $category) public function setCategory(ActivityReasonCategory $category)
@ -128,7 +141,6 @@ class ActivityReason
* Set active * Set active
* *
* @param boolean $active * @param boolean $active
*
* @return ActivityReason * @return ActivityReason
*/ */
public function setActive($active) public function setActive($active)

View File

@ -1,7 +1,6 @@
<?php <?php
/* /*
*
* Copyright (C) 2015, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop> * Copyright (C) 2015, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -20,36 +19,60 @@
namespace Chill\ActivityBundle\Entity; namespace Chill\ActivityBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
/** /**
* ActivityReasonCategory * Class ActivityReasonCategory
*
* @package Chill\ActivityBundle\Entity
* @ORM\Entity()
* @ORM\Table(null)
* @ORM\HasLifecycleCallbacks()
*/ */
class ActivityReasonCategory class ActivityReasonCategory
{ {
/** /**
* @var integer * @var integer
*
* @ORM\Id
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/ */
private $id; private $id;
/** /**
* @var string * @var string
* @ORM\Column(type="json_array")
*/ */
private $name; private $name;
/** /**
* @var boolean * @var boolean
* @ORM\Column(type="boolean")
*/ */
private $active = true; private $active = true;
/** @var ArrayCollection array of ActivityReason */ /**
* Array of ActivityReason
* @var ArrayCollection
* @ORM\OneToMany(
* targetEntity="Chill\ActivityBundle\Entity\ActivityReason",
* mappedBy="category")
*/
private $reasons; private $reasons;
/**
* ActivityReasonCategory constructor.
*/
public function __construct() public function __construct()
{ {
$this->reasons = new ArrayCollection(); $this->reasons = new ArrayCollection();
} }
/**
* @return string
*/
public function __toString() public function __toString()
{ {
return 'ActivityReasonCategory('.$this->getName('x').')'; return 'ActivityReasonCategory('.$this->getName('x').')';
@ -69,7 +92,6 @@ class ActivityReasonCategory
* Set name * Set name
* *
* @param array $name * @param array $name
*
* @return ActivityReasonCategory * @return ActivityReasonCategory
*/ */
public function setName($name) public function setName($name)

View File

@ -20,21 +20,37 @@
namespace Chill\ActivityBundle\Entity; namespace Chill\ActivityBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/** /**
* ActivityType * Class ActivityType
*
* @package Chill\ActivityBundle\Entity
* @ORM\Entity()
* @ORM\Table(null)
* @ORM\HasLifecycleCallbacks()
*/ */
class ActivityType class ActivityType
{ {
/** /**
* @var integer * @var integer
*
* @ORM\Id
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/ */
private $id; private $id;
/** /**
* @var array * @var array
* @ORM\Column(type="json_array")
*/ */
private $name; private $name;
/**
* @var bool
* @ORM\Column(type="boolean")
*/
private $active = true; private $active = true;
@ -52,7 +68,6 @@ class ActivityType
* Set name * Set name
* *
* @param array $name * @param array $name
*
* @return ActivityType * @return ActivityType
*/ */
public function setName($name) public function setName($name)
@ -86,34 +101,31 @@ class ActivityType
} }
/** /**
* get active * Get active
*
* return true if the type is active. * return true if the type is active.
* *
* @return boolean true if the type is active * @return boolean
*/ */
public function getActive() { public function getActive() {
return $this->active; return $this->active;
} }
/** /**
* get active * Is active
*
* return true if the type is active * return true if the type is active
* *
* @return boolean true if the type is active * @return boolean
*/ */
public function isActive() { public function isActive() {
return $this->getActive(); return $this->getActive();
} }
/** /**
* set active * Set active
*
* set to true if the type is active * set to true if the type is active
* *
* @param boolean $active * @param boolean $active
* @return \Chill\ActivityBundle\Entity\ActivityType * @return ActivityType
*/ */
public function setActive($active) { public function setActive($active) {
$this->active = $active; $this->active = $active;

View File

@ -1,31 +0,0 @@
Chill\ActivityBundle\Entity\Activity:
type: entity
table: null
id:
id:
type: integer
id: true
generator:
strategy: AUTO
fields:
date:
type: datetime
durationTime:
type: time
remark:
type: text
attendee:
type: boolean
manyToMany:
reasons:
targetEntity: Chill\ActivityBundle\Entity\ActivityReason
manyToOne:
user:
targetEntity: Chill\MainBundle\Entity\User
scope:
targetEntity: Chill\MainBundle\Entity\Scope
type:
targetEntity: Chill\ActivityBundle\Entity\ActivityType
person:
targetEntity: Chill\PersonBundle\Entity\Person
lifecycleCallbacks: { }

View File

@ -1,18 +0,0 @@
Chill\ActivityBundle\Entity\ActivityReason:
type: entity
table: null
id:
id:
type: integer
id: true
generator:
strategy: AUTO
fields:
name:
type: json_array
active:
type: boolean
manyToOne:
category:
targetEntity: Chill\ActivityBundle\Entity\ActivityReasonCategory
lifecycleCallbacks: { }

View File

@ -1,19 +0,0 @@
Chill\ActivityBundle\Entity\ActivityReasonCategory:
type: entity
table: null
id:
id:
type: integer
id: true
generator:
strategy: AUTO
fields:
name:
type: json_array
active:
type: boolean
oneToMany:
reasons:
targetEntity: Chill\ActivityBundle\Entity\ActivityReason
mappedBy: category
lifecycleCallbacks: { }

View File

@ -1,16 +0,0 @@
Chill\ActivityBundle\Entity\ActivityType:
type: entity
table: null
id:
id:
type: integer
id: true
generator:
strategy: AUTO
fields:
name:
type: json_array
active:
type: boolean
default: true
lifecycleCallbacks: { }