mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
Allow to add multiple participation
The participationController accept a new parameter : `persons_ids`, which must receive a comma-separated list of person ids. A participation will be create for all those peoples. The `new` and `create` actions does not allow to receive both `person_id` and `persons_ids`. Tests are added. ref #6
This commit is contained in:
@@ -9,7 +9,7 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
/**
|
||||
* Participation
|
||||
*/
|
||||
class Participation implements HasCenterInterface, HasScopeInterface
|
||||
class Participation implements HasCenterInterface, HasScopeInterface, \ArrayAccess
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
@@ -218,6 +218,11 @@ class Participation implements HasCenterInterface, HasScopeInterface
|
||||
*/
|
||||
public function isConsistent(ExecutionContextInterface $context)
|
||||
{
|
||||
|
||||
if ($this->getEvent() === NULL || $this->getRole() === NULL || $this->getStatus() === NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->getRole()->getType()->getId() !==
|
||||
$this->getEvent()->getType()->getId()) {
|
||||
$context->buildViolation('The role is not allowed with this event type')
|
||||
@@ -233,4 +238,52 @@ class Participation implements HasCenterInterface, HasScopeInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return in_array($offset, array(
|
||||
'person', 'role', 'status', 'event'
|
||||
));
|
||||
}
|
||||
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
switch ($offset) {
|
||||
case 'person':
|
||||
return $this->getPerson();
|
||||
break;
|
||||
case 'role':
|
||||
return $this->getRole();
|
||||
break;
|
||||
case 'status':
|
||||
return $this->getStatus();
|
||||
break;
|
||||
case 'event':
|
||||
return $this->getEvent();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
switch($offset) {
|
||||
case 'person':
|
||||
return $this->setPerson($value);
|
||||
break;
|
||||
case 'role':
|
||||
return $this->setRole($value);
|
||||
break;
|
||||
case 'status':
|
||||
return $this->setStatus($value);
|
||||
break;
|
||||
case 'event':
|
||||
return $this->setEvent($value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
$this->offsetSet($offset, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user