sf4 deprecated: migrate Doctrine ORM mapping to annotation

This commit is contained in:
2020-07-24 16:46:46 +02:00
parent 97d3afba9b
commit d39666bf8e
10 changed files with 423 additions and 286 deletions

View File

@@ -28,36 +28,74 @@ use Chill\MainBundle\Entity\User;
/**
* AccompanyingPeriod
*
* @ORM\Entity()
* @ORM\Table(name="chill_person_accompanying_period")
*/
class AccompanyingPeriod
{
/** @var integer */
/**
* @var integer
*
* @ORM\Id
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/** @var \DateTime */
/**
* @var \DateTime
*
* @ORM\Column(type="date")
*/
private $openingDate;
/** @var \DateTime */
private $closingDate;
/**
* @var \DateTime
*
* @ORM\Column(type="date", nullable=true)
*/
private $closingDate = null;
/** @var string */
/**
* @var string
*
* @ORM\Column(type="text")
*/
private $remark = '';
/** @var \Chill\PersonBundle\Entity\Person */
/**
* @var Person
*
* @ORM\ManyToOne(
* targetEntity="Chill\PersonBundle\Entity\Person",
* inversedBy="accompanyingPeriods",
* cascade={"refresh"})
*/
private $person;
/** @var AccompanyingPeriod\ClosingMotive */
/**
* @var AccompanyingPeriod\ClosingMotive
*
* @ORM\ManyToOne(
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive")
* @ORM\JoinColumn(nullable=true)
*/
private $closingMotive = null;
/**
* The user making the accompanying
*
* @var User
*
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
* @ORM\JoinColumn(nullable=true)
*/
private $user;
/**
*
* AccompanyingPeriod constructor.
*
* @param \DateTime $dateOpening
* @uses AccompanyingPeriod::setClosingDate()
*/
@@ -125,7 +163,6 @@ class AccompanyingPeriod
}
/**
*
* @return boolean
*/
public function isOpen(): bool
@@ -170,14 +207,14 @@ class AccompanyingPeriod
/**
* Set person.
*
*
* For consistency, you should use Person::addAccompanyingPeriod instead.
*
* @param \Chill\PersonBundle\Entity\Person $person
* @param Person $person
* @return AccompanyingPeriod
* @see Person::addAccompanyingPeriod
*/
public function setPerson(\Chill\PersonBundle\Entity\Person $person = null)
public function setPerson(Person $person = null)
{
$this->person = $person;
@@ -187,18 +224,25 @@ class AccompanyingPeriod
/**
* Get person
*
* @return \Chill\PersonBundle\Entity\Person
* @return Person
*/
public function getPerson()
{
return $this->person;
}
/**
* @return AccompanyingPeriod\ClosingMotive
*/
public function getClosingMotive()
{
return $this->closingMotive;
}
/**
* @param AccompanyingPeriod\ClosingMotive|null $closingMotive
* @return $this
*/
public function setClosingMotive(AccompanyingPeriod\ClosingMotive $closingMotive = null)
{
$this->closingMotive = $closingMotive;
@@ -224,14 +268,19 @@ class AccompanyingPeriod
return end($periods) === $this;
}
/**
*/
public function reOpen()
{
$this->setClosingDate(null);
$this->setClosingMotive(null);
}
/// VALIDATION function
public function isDateConsistent(ExecutionContextInterface $context) {
/**
* Validation function
*/
public function isDateConsistent(ExecutionContextInterface $context)
{
if ($this->isOpen()) {
return;
}
@@ -248,7 +297,8 @@ class AccompanyingPeriod
*
* @return boolean
*/
public function isClosingAfterOpening() {
public function isClosingAfterOpening()
{
$diff = $this->getOpeningDate()->diff($this->getClosingDate());
if ($diff->invert === 0) {
@@ -258,11 +308,18 @@ class AccompanyingPeriod
}
}
/**
* @return User|null
*/
function getUser(): ?User
{
return $this->user;
}
/**
* @param User $user
* @return AccompanyingPeriod
*/
function setUser(User $user): self
{
$this->user = $user;
@@ -270,5 +327,4 @@ class AccompanyingPeriod
return $this;
}
}