private function buildUser($login)
 {
     $user = new User();
     $user->setName($login . ' name');
     $user->setLogin($login);
     $user->setEmail($login . '@domain.com');
     $user->setAvatar($login . '.png');
     return $user;
 }
 private function buildUser()
 {
     $user = new User();
     $user->setName('Steve Jobs');
     $user->setLogin('steve');
     $user->setLogin('*****@*****.**');
     $user->setAvatar('steve.png');
     return $user;
 }
Ejemplo n.º 3
0
    $steve->setLogin('sjobs');
    $steve->setEmail('*****@*****.**');
    $steve->setAvatar('steve.jpg');
    $subscription = new Subscription();
    $subscription->setUser($steve);
    $subscription->setStatus(1);
    $subscription->setStarted(new \Datetime());
    $steve->setSubscription($subscription);
    $entityManager->persist($subscription);
}
$steve->setName('Steve Wonder');
$entityManager->persist($steve);
echo $steve->getName(), "\n";
$bill = $entityManager->getRepository('DoctrineNaPratica\\Model\\User')->findOneBy(array('login' => 'bill'));
if (!$bill) {
    $bill = new User();
    $bill->setName('Bill Gates');
    $bill->setLogin('bill');
    $bill->setEmail('*****@*****.**');
    $bill->setAvatar('bill.jpg');
    $entityManager->persist($bill);
}
echo $bill->getId(), "\n";
try {
    $entityManager->flush();
} catch (Exception $e) {
    echo $e->getMessage();
}
echo $bill->getId(), "\n";
$entityManager->remove($bill);
$entityManager->flush();