diff --git a/src/Controller/MigrationController.php b/src/Controller/MigrationController.php index fcc9c16..c2afd53 100755 --- a/src/Controller/MigrationController.php +++ b/src/Controller/MigrationController.php @@ -4,6 +4,7 @@ namespace App\Controller; //use FOS\RestBundle\Controller\Annotations\Get; //use FOS\RestBundle\Controller\Annotations\Route; use App\Entity\Choice; +use App\Entity\Comment; use App\Entity\StackOfVotes; use App\Repository\PollRepository; use App\Service\MailService; @@ -135,6 +136,23 @@ class MigrationController extends FramadateController { } + $res_votes = $bdd->query( 'SELECT * FROM fd_comment' ); + while ( $d = $res_votes->fetch( \PDO::FETCH_OBJ ) ) { + + $pollSlug = $d->poll_id; + $poll = $pollsBySlug[ $pollSlug ]; + $newComment = new Comment(); + $poll->addComment($newComment); + + $newComment->setPoll($poll) + ->setCreatedAt( date_create($d->date)) + ->setText( $d->comment); + // TODO update entities +// ->setPseudo( $d->pseudo) + $em->persist( $newComment ); + ; + } + // $em->flush(); // gather objects diff --git a/src/Entity/Comment.php b/src/Entity/Comment.php index c715869..ed20d7c 100755 --- a/src/Entity/Comment.php +++ b/src/Entity/Comment.php @@ -25,6 +25,13 @@ class Comment { */ private $owner; + /** + * @ORM\Column(type="string") + * @Serializer\Type("string") + * @Serializer\Expose() + */ + private $pseudo; + /** * @ORM\Column(type="text") * @Serializer\Type("string")