Created
March 28, 2014 15:56
-
-
Save meshenka/9836117 to your computer and use it in GitHub Desktop.
[PDOException] SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'spread-Nm\SearchBu ndle\Entity\User-4-GLOBAL' for key 'PRIMARY'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Nm\SearchBundle\Command; | |
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | |
use Symfony\Component\Console\Input\InputInterface; | |
use Symfony\Component\Console\Output\OutputInterface; | |
use Nm\SearchBundle\Entity\GroupNotification; | |
use Nm\SearchBundle\Entity\UserNotification; | |
use Nm\SearchBundle\Entity\User; | |
use Nm\SearchBundle\Entity\Action; | |
class DataFixtureCommand extends ContainerAwareCommand | |
{ | |
protected function configure() | |
{ | |
$this | |
->setName('nm:data:load') | |
->setDescription('create data'); | |
} | |
protected function execute(InputInterface $input, OutputInterface $output) | |
{ | |
$em = $this->getContainer()->get('doctrine')->getManager(); | |
$user = new User(); | |
$user | |
->setLogin("test") | |
->setEmail("test@no.log") | |
; | |
$userNotif = new UserNotification(); | |
$userNotif | |
->setTitle("user test") | |
->setBody("Yata") | |
->setUserName('Demo user'); | |
$groupNotif = new GroupNotification(); | |
$groupNotif | |
->setTitle("user test") | |
->setBody("Yata le group") | |
->setGroupName('Nm Group'); | |
$user->addNotification($userNotif); | |
$user->addNotification($groupNotif); | |
$em->persist($user); | |
$em->flush(); //must flush before creating any Action | |
$this->getContainer()->get('highco.timeline.manager')->push(Action::create($user, 'control', 'The world')); | |
$this->getContainer()->get('highco.timeline.manager')->push(Action::create($user, 'share', $groupNotif)); | |
$this->getContainer()->get('highco.timeline.manager')->push(Action::create($user, 'like', $user)); | |
$output->writeln('<info>Data Created</info>'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment