1
0
mirror of https://framagit.org/tykayn/date-poll-api synced 2023-08-25 08:23:11 +02:00

default created at

This commit is contained in:
Baptiste Lemoine 2019-11-27 16:39:52 +01:00
parent c02edb5a76
commit d6cbd23d3f
5 changed files with 21 additions and 15 deletions

View File

@ -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( [

View File

@ -37,7 +37,7 @@ class Comment {
private $poll;
function __construct() {
$this->setCreatedAt( new \DateTime() );
$this->setCreatedAt( new \DateTime() );
}
public function getId(): ?int {

View File

@ -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;
}

View File

@ -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 {

12
src/Entity/timedTrait.php Normal file
View File

@ -0,0 +1,12 @@
<?php
namespace App\Traits;
use Doctrine\ORM\Mapping as ORM;
trait Timed {
/**
* @ORM\Column(type="datetime" , options={"default"="CURRENT_TIMESTAMP"})
*/
private $createdAt;
}