sf4 deprecated: migrate Doctrine ORM mapping to annotation

This commit is contained in:
2020-07-24 18:57:58 +02:00
parent c8c76e5a8d
commit ad8c1bbe9f
10 changed files with 291 additions and 212 deletions

View File

@@ -1,43 +1,83 @@
<?php
/*
* Chill is a software for social workers
*
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Chill\EventBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\Scope;
use Chill\PersonBundle\Entity\Person;
use Chill\MainBundle\Entity\HasScopeInterface;
use Chill\MainBundle\Entity\HasCenterInterface;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
/**
* Participation
* Class Participation
*
* @package Chill\EventBundle\Entity
* @ORM\Entity(
* repositoryClass="Chill\EventBundle\Repository\ParticipationRepository")
* @ORM\Table(name="chill_event_participation")
* @ORM\HasLifecycleCallbacks()
*/
class Participation implements HasCenterInterface, HasScopeInterface, \ArrayAccess
{
/**
* @var integer
*
* @ORM\Id
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var \DateTime
* @ORM\Column(type="datetime")
*/
private $lastUpdate;
/**
* @var \Chill\EventBundle\Entity\Event
* @var Event
* @ORM\ManyToOne(
* targetEntity="Chill\EventBundle\Entity\Event",
* inversedBy="participations")
*/
private $event;
/**
* @var \Chill\PersonBundle\Entity\Person
* @var Person
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\Person")
*/
private $person;
/**
* @var \Chill\EventBundle\Entity\Role
* @var Role
* @ORM\ManyToOne(targetEntity="Chill\EventBundle\Entity\Role")
*/
private $role;
/**
* @var \Chill\EventBundle\Entity\Status
* @var Status
* @ORM\ManyToOne(targetEntity="Chill\EventBundle\Entity\Status")
*/
private $status;
@@ -56,7 +96,6 @@ class Participation implements HasCenterInterface, HasScopeInterface, \ArrayAcce
* Set lastUpdate
*
* @param \DateTime $lastUpdate
*
* @return Participation
*/
protected function update()
@@ -80,11 +119,10 @@ class Participation implements HasCenterInterface, HasScopeInterface, \ArrayAcce
/**
* Set event
*
* @param \Chill\EventBundle\Entity\Event $event
*
* @param Event $event
* @return Participation
*/
public function setEvent(\Chill\EventBundle\Entity\Event $event = null)
public function setEvent(Event $event = null)
{
if ($this->event !== $event) {
$this->update();
@@ -98,7 +136,7 @@ class Participation implements HasCenterInterface, HasScopeInterface, \ArrayAcce
/**
* Get event
*
* @return \Chill\EventBundle\Entity\Event
* @return Event
*/
public function getEvent()
{
@@ -108,11 +146,10 @@ class Participation implements HasCenterInterface, HasScopeInterface, \ArrayAcce
/**
* Set person
*
* @param \Chill\PersonBundle\Entity\Person $person
*
* @param Person $person
* @return Participation
*/
public function setPerson(\Chill\PersonBundle\Entity\Person $person = null)
public function setPerson(Person $person = null)
{
if ($person !== $this->person) {
$this->update();
@@ -126,7 +163,7 @@ class Participation implements HasCenterInterface, HasScopeInterface, \ArrayAcce
/**
* Get person
*
* @return \Chill\PersonBundle\Entity\Person
* @return Person
*/
public function getPerson()
{
@@ -136,11 +173,10 @@ class Participation implements HasCenterInterface, HasScopeInterface, \ArrayAcce
/**
* Set role
*
* @param \Chill\EventBundle\Entity\Role $role
*
* @param Role $role
* @return Participation
*/
public function setRole(\Chill\EventBundle\Entity\Role $role = null)
public function setRole(Role $role = null)
{
if ($role !== $this->role) {
$this->update();
@@ -153,7 +189,7 @@ class Participation implements HasCenterInterface, HasScopeInterface, \ArrayAcce
/**
* Get role
*
* @return \Chill\EventBundle\Entity\Role
* @return Role
*/
public function getRole()
{
@@ -163,11 +199,10 @@ class Participation implements HasCenterInterface, HasScopeInterface, \ArrayAcce
/**
* Set status
*
* @param \Chill\EventBundle\Entity\Status $status
*
* @param Status $status
* @return Participation
*/
public function setStatus(\Chill\EventBundle\Entity\Status $status = null)
public function setStatus(Status $status = null)
{
if ($this->status !== $status) {
$this->update();
@@ -181,13 +216,16 @@ class Participation implements HasCenterInterface, HasScopeInterface, \ArrayAcce
/**
* Get status
*
* @return \Chill\EventBundle\Entity\Status
* @return Status
*/
public function getStatus()
{
return $this->status;
}
/**
* @return Center
*/
public function getCenter()
{
if ($this->getEvent() === NULL) {
@@ -197,7 +235,10 @@ class Participation implements HasCenterInterface, HasScopeInterface, \ArrayAcce
return $this->getEvent()->getCenter();
}
/**
* @return Scope
*/
public function getScope()
{
if ($this->getEvent() === NULL) {
@@ -237,14 +278,22 @@ class Participation implements HasCenterInterface, HasScopeInterface, \ArrayAcce
->addViolation();
}
}
/**
* @param mixed $offset
* @return bool
*/
public function offsetExists($offset)
{
return in_array($offset, array(
'person', 'role', 'status', 'event'
));
}
/**
* @param mixed $offset
* @return Event|Role|Status|Person|mixed
*/
public function offsetGet($offset)
{
switch ($offset) {
@@ -262,7 +311,12 @@ class Participation implements HasCenterInterface, HasScopeInterface, \ArrayAcce
break;
}
}
/**
* @param mixed $offset
* @param mixed $value
* @return Participation|void
*/
public function offsetSet($offset, $value)
{
switch($offset) {
@@ -280,7 +334,10 @@ class Participation implements HasCenterInterface, HasScopeInterface, \ArrayAcce
break;
}
}
/**
* @param mixed $offset
*/
public function offsetUnset($offset)
{
$this->offsetSet($offset, null);