public function insert($data) { $entity = new \SandboxContact\Entity\Contato(); $entity->setCreated(new \DateTime('now')); $entity->setCreatedBy($this->getUser()); $this->hydrate($data, $entity); $this->getEventManager()->trigger(__FUNCTION__ . '.pre', $this, $entity); $this->persist($entity); $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, $entity); return $entity; }
public function load(ObjectManager $manager) { $this->manager = $manager; foreach ($this->getFixture() as $i => $fixture) { $reference = $i + 1; $contato = new \SandboxContact\Entity\Contato(); $contato->setEmail($fixture['email']); $contato->setAssunto($fixture['assunto']); $contato->setMensagem($fixture['mensagem']); $userReferenced = $this->getReferenceToEntity($reference); $contato->setCreated(new \DateTime('now')); $contato->setCreatedBy($userReferenced); $this->manager->persist($contato); $this->manager->flush(); $this->addReference("contato-{$reference}", $contato); } }