diff --git a/src/DataFixtures/AppPollFixtures.php b/src/DataFixtures/AppPollFixtures.php index 5245756..ae5c00f 100644 --- a/src/DataFixtures/AppPollFixtures.php +++ b/src/DataFixtures/AppPollFixtures.php @@ -28,12 +28,9 @@ class AppPollFixtures extends Fixture { $poll = new Poll(); $poll->setTitle( 'citron ou orange' ); - $poll->setKind( 'text' ); $poll->setDescription( 'votre sorbert préféré' ); $poll->setAdminKey( uniqid() ); $poll->setModificationPolicy( 'nobody' ); - - $poll->setExpiracyDate( new DateTime() ); $poll->setMailOnVote( true ); $poll->setOwner( $owner ); $owner->addPoll( $poll ); @@ -74,11 +71,10 @@ class AppPollFixtures extends Fixture { $poll->setTitle( 'démo sondage de texte avec deux commentaires' ); $poll->setDescription( 'description du sondage 2' ); - $poll->setKind( 'text' ); + $poll->setAdminKey( uniqid() ); $poll->setModificationPolicy( 'self' ); $poll->setMailOnComment( true ); - $poll->setExpiracyDate( new DateTime() ); $poll->addTextChoiceArray( [ 'un truc', 'deux trucs' ] ); @@ -111,14 +107,14 @@ class AppPollFixtures extends Fixture { // // $poll = new Poll(); // $poll->setTitle( 'accès restreint sondage de texte' ); -// $poll->setKind( 'text' ); +// $poll ; // $poll->setPassword( md5( 'mot_de_passe_super' ) ); // $poll->setModificationPolicy( 'everybody' ); // $poll->setDescription( 'description du sondage a accès restreint. le mot de passe est mot_de_passe_super' ); // $poll->setAdminKey( uniqid() ); // $poll->setCustomUrl( 'boudoum_podom_podom' ); // -// $poll->setExpiracyDate( new DateTime() ); +// $poll ; // $poll->setMailOnComment( true ); // $poll->setMailOnVote( true ); // $poll->setOwner( $owner ); @@ -145,7 +141,6 @@ class AppPollFixtures extends Fixture { $poll->setTitle( "c'est pour aujourdhui ou pour demain" ) ->setDescription( 'Vous avez le choix dans la date' ) - ->setExpiracyDate( new DateTime() ) ->setKind( 'date' ) ->setOwner( $owner ) ->addChoice( $choice ) @@ -156,8 +151,6 @@ class AppPollFixtures extends Fixture { $poll = new Poll(); $poll->setTitle( 'dessin animé préféré' ) ->setDescription( 'choisissez votre animé préféré' ) - ->setExpiracyDate( new DateTime() ) - ->setKind( 'text' ) ->setOwner( $owner ) ->setModificationPolicy( 'self' ) ->addTextChoiceArray( [ diff --git a/src/Entity/Comment.php b/src/Entity/Comment.php index 2a9edca..713de7d 100644 --- a/src/Entity/Comment.php +++ b/src/Entity/Comment.php @@ -37,7 +37,7 @@ class Comment { private $poll; function __construct() { - $this->setCreatedAt( new \DateTime() ); + $this->setCreatedAt( new \DateTime() ); } public function getId(): ?int { diff --git a/src/Entity/Owner.php b/src/Entity/Owner.php index 4ad6cc7..6ecfe6d 100644 --- a/src/Entity/Owner.php +++ b/src/Entity/Owner.php @@ -50,7 +50,7 @@ class Owner { */ private $modifierToken; /** - * @ORM\Column(type="datetime") + * @ORM\Column(type="datetime" , options={"default"="CURRENT_TIMESTAMP"}) */ private $createdAt; @@ -62,6 +62,7 @@ class Owner { $this->setModifierToken( uniqid() ); } + public function getId(): ?int { return $this->id; } diff --git a/src/Entity/Poll.php b/src/Entity/Poll.php index 618356c..c28a115 100644 --- a/src/Entity/Poll.php +++ b/src/Entity/Poll.php @@ -40,7 +40,7 @@ class Poll { */ public $description; /** - * @ORM\Column(type="datetime") + * @ORM\Column(type="datetime" , options={"default"="CURRENT_TIMESTAMP"}) * @Serializer\Expose() */ public $creationDate; @@ -60,7 +60,7 @@ class Poll { * @Serializer\Type("string") * @Serializer\Expose() */ - public $kind; + public $kind = 'text'; /** * array of possible answer to each choice, by default: "yes" or nothing only. * could be also "yes", "maybe", "no". extensible to anything @@ -158,7 +158,7 @@ class Poll { public function addDaysToDate( \DateTime $date, int $days ) { $st = strtotime( $date->getTimestamp() . ' + ' . $days . ' days' ); - return new \DateTime( "@$st" ); + return new \DateTime( $st ); } public function getId(): ?int { diff --git a/src/Entity/timedTrait.php b/src/Entity/timedTrait.php new file mode 100644 index 0000000..2621137 --- /dev/null +++ b/src/Entity/timedTrait.php @@ -0,0 +1,12 @@ +