/**
  * {@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();
 }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
 public function findOneByUserCategoryKey(User $user, $category, $key)
 {
     $query = $this->getEntityManager()->createQuery('
           SELECT r FROM VirtualPersistBundle:Record r
           WHERE r.owner = :user AND r.category = :category AND r.aKey = :key')->setParameter('user', $user->getId())->setParameter('category', $category)->setParameter('key', $key);
     try {
         $result = $query->getSingleResult();
         return $result;
     } catch (\Exception $e) {
         // The show must go on.
         return null;
     }
 }
Exemplo n.º 4
0
 /**
  * {@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();
 }
Exemplo n.º 5
0
 /**
  * Set user
  *
  * @param \VirtualPersistAPI\VirtualPersistBundle\Entity\User $user
  * @return Log
  */
 public function setUser(\VirtualPersistAPI\VirtualPersistBundle\Entity\User $user)
 {
     $this->user = $user->getId();
     $this->userUUID = $user->getUuid();
     return $this;
 }