mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-27 18:13:48 +00:00
add validation to single task controller::new
This commit is contained in:
@@ -8,11 +8,17 @@ use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Chill\MainBundle\Entity\HasScopeInterface;
|
||||
use Chill\MainBundle\Entity\HasCenterInterface;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Chill\MainBundle\Validator\Constraints\Entity\UserCircleConsistency;
|
||||
|
||||
/**
|
||||
* AbstractTask
|
||||
*
|
||||
* @ORM\MappedSuperclass()
|
||||
* @UserCircleConsistency(
|
||||
* "CHILL_TASK_TASK_SHOW",
|
||||
* getUserFunction="getAssignee"
|
||||
* )
|
||||
*/
|
||||
abstract class AbstractTask implements HasScopeInterface, HasCenterInterface
|
||||
{
|
||||
@@ -35,6 +41,7 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="title", type="text")
|
||||
* @Assert\NotBlank()
|
||||
*/
|
||||
private $title = '';
|
||||
|
||||
@@ -60,6 +67,7 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="\Chill\PersonBundle\Entity\Person"
|
||||
* )
|
||||
* @Assert\NotNull()
|
||||
*/
|
||||
private $person;
|
||||
|
||||
@@ -69,6 +77,7 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="\Chill\MainBundle\Entity\Scope"
|
||||
* )
|
||||
* @Assert\NotNull()
|
||||
*/
|
||||
private $circle;
|
||||
|
||||
@@ -81,7 +90,7 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface
|
||||
*/
|
||||
public function setType($type)
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->type = (string) $type;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -129,7 +138,7 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
$this->title = (string) $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -153,7 +162,7 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface
|
||||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
$this->description = (string) $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@
|
||||
namespace Chill\TaskBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* SingleTask
|
||||
@@ -25,6 +26,11 @@ class SingleTask extends AbstractTask
|
||||
* @var \DateTime
|
||||
*
|
||||
* @ORM\Column(name="start_date", type="date", nullable=true)
|
||||
* @Assert\Date()
|
||||
* @Assert\Expression(
|
||||
* "value === null or value < this.getEndDate()",
|
||||
* message="The start date must be before the end date"
|
||||
* )
|
||||
*/
|
||||
private $startDate;
|
||||
|
||||
@@ -32,6 +38,7 @@ class SingleTask extends AbstractTask
|
||||
* @var \DateTime
|
||||
*
|
||||
* @ORM\Column(name="end_date", type="date", nullable=true)
|
||||
* @Assert\Date()
|
||||
*/
|
||||
private $endDate;
|
||||
|
||||
|
Reference in New Issue
Block a user