mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
add the possibility to add a participation of a person to an event
ref #5
This commit is contained in:
@@ -2,10 +2,14 @@
|
||||
|
||||
namespace Chill\EventBundle\Entity;
|
||||
|
||||
use Chill\MainBundle\Entity\HasScopeInterface;
|
||||
use Chill\MainBundle\Entity\HasCenterInterface;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
|
||||
/**
|
||||
* Participation
|
||||
*/
|
||||
class Participation
|
||||
class Participation implements HasCenterInterface, HasScopeInterface
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
@@ -183,4 +187,50 @@ class Participation
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
public function getCenter()
|
||||
{
|
||||
if ($this->getEvent() === NULL) {
|
||||
throw new \RuntimeException('The event is not linked with this instance. '
|
||||
. 'You should initialize the event with a valid center before.');
|
||||
}
|
||||
|
||||
return $this->getEvent()->getCenter();
|
||||
}
|
||||
|
||||
public function getScope()
|
||||
{
|
||||
if ($this->getEvent() === NULL) {
|
||||
throw new \RuntimeException('The event is not linked with this instance. '
|
||||
. 'You should initialize the event with a valid center before.');
|
||||
}
|
||||
|
||||
return $this->getEvent()->getCircle();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that :
|
||||
*
|
||||
* - the role can be associated with this event type
|
||||
* - the status can be associated with this event type
|
||||
*
|
||||
* @param ExecutionContextInterface $context
|
||||
*/
|
||||
public function isConsistent(ExecutionContextInterface $context)
|
||||
{
|
||||
if ($this->getRole()->getType()->getId() !==
|
||||
$this->getEvent()->getType()->getId()) {
|
||||
$context->buildViolation('The role is not allowed with this event type')
|
||||
->atPath('role')
|
||||
->addViolation();
|
||||
}
|
||||
|
||||
if ($this->getStatus()->getType()->getId() !==
|
||||
$this->getEvent()->getType()->getId()) {
|
||||
$context->buildViolation('The status is not allowed with this event type')
|
||||
->atPath('status')
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user