Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

set owner symfony

use AppBundleEntityPost; //at top of controller

$em = $this->getDoctrine()->getManager();
$user = $this->container->get('security.token_storage')->getToken()->getUser();
$post = new Post();
$em->persist( $post );
$post->setOwner( $user );
// set other fields in your post entity
$em->flush();
 
PREVIOUS NEXT
Tagged: #set #owner #symfony
ADD COMMENT
Topic
Name
1+4 =