mirror of
https://framagit.org/tykayn/date-poll-api
synced 2023-08-25 08:23:11 +02:00
⚡ creation from an existing user works
This commit is contained in:
parent
6b4994b35a
commit
7340b020ec
@ -98,8 +98,8 @@ class DefaultController extends AbstractController {
|
|||||||
$data = json_decode( $data, true );
|
$data = json_decode( $data, true );
|
||||||
// die( $data );
|
// die( $data );
|
||||||
$em = $this->getDoctrine()->getRepository( Owner::class );
|
$em = $this->getDoctrine()->getRepository( Owner::class );
|
||||||
$foundOwner = $em->findByEmail( $data[ 'owner' ][ 'email' ] );
|
$foundOwner = $em->findOneBy( [ 'email' => $data[ 'owner' ][ 'email' ] ] );
|
||||||
die( $foundOwner );
|
|
||||||
$userWasFound = false;
|
$userWasFound = false;
|
||||||
if ( ! $foundOwner ) {
|
if ( ! $foundOwner ) {
|
||||||
//create a new owner
|
//create a new owner
|
||||||
@ -109,12 +109,15 @@ class DefaultController extends AbstractController {
|
|||||||
$owner->setEmail( $data[ 'owner' ][ 'email' ] );
|
$owner->setEmail( $data[ 'owner' ][ 'email' ] );
|
||||||
$foundOwner = $owner;
|
$foundOwner = $owner;
|
||||||
} else {
|
} else {
|
||||||
|
// die( $foundOwner->getPseudo() );
|
||||||
$userWasFound = true;
|
$userWasFound = true;
|
||||||
}
|
}
|
||||||
// link the owner and the poll
|
// link the owner and the poll
|
||||||
$newpoll->setOwner( $foundOwner );
|
$newpoll->setOwner( $foundOwner );
|
||||||
$foundOwner->addPoll( $newpoll );
|
$foundOwner->addPoll( $newpoll );
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
$em->persist( $newpoll );
|
$em->persist( $newpoll );
|
||||||
|
$em->persist( $foundOwner );
|
||||||
$em->flush();
|
$em->flush();
|
||||||
$precision = '';
|
$precision = '';
|
||||||
if ( $userWasFound ) {
|
if ( $userWasFound ) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user