/** * {@inheritDoc} */ public function load(ObjectManager $manager) { $data = $this->userFixtureDataSource(); // Have to keep a reference to all the user objects // or else they can't be flushed all at once. $items = array(); $user = new User(); foreach ($data['User'] as $item) { $user = new User(); $user->setUuid($item['uuid'])->setUsername($item['username'])->setPassword($item['password'])->setEmail($item['email'])->setIsActive($item['is_active']); $this->addReference($user->getUuid(), $user); $items[] = $user; $manager->persist($user); } $manager->flush(); $items = array(); foreach ($data['Record'] as $item) { $record = new Record(); $record->setCategory($item['category'])->setKey($item['aKey'])->setData($item['data'])->setOwner($manager->merge($this->getReference($item['owner_uuid']))); $timestamp = new \DateTime('now'); if (!empty($item['timestamp'])) { $timestamp->setTimestamp($item['timestamp']); } $record->setTimestamp($timestamp); $items[] = $record; $manager->persist($record); } $manager->flush(); }
public function getAll() { try { $users = $this->_em->createQuery('SELECT u FROM VirtualPersistBundle:User u')->getResult(); if (!empty($users)) { return $users; } } catch (\Exception $e) { } $user = new User(); $user->setUuid('<none>'); return array($user); }
/** * {@inheritDoc} */ public function load(ObjectManager $manager) { $data = $this->userFixtureDataSource(); // Have to keep a reference to all the user objects // or else they can't be flushed all at once. $users = array(); foreach ($data as $item) { $user = new User(); $user->setUuid($item['uuid'])->setPassword($item['password'])->setUsername($item['username'])->setEmail($item['email']); $this->addReference($user->getUuid(), $user); $users[] = $user; $manager->persist($user); } $manager->flush(); }