Beispiel #1
0
 public function find($id)
 {
     $order = $this->ordersRepository->find($id);
     $client = $this->clientsRepository->findBy(['id' => $order->getClientId()])->current();
     $ptype = $this->ptypesRepository->findBy(['id' => $order->getPtypeId()])->current();
     $user = $this->usersRepository->findBy(['id' => $order->getUserId()])->current();
     $sql = $this->ordersRepository->getItemTable()->getSql();
     $select = $sql->select();
     $select->join('products', 'order_items.product_id = products.id', ['product_name' => 'name'])->where(['order_id' => $order->getId()]);
     $items = $this->ordersRepository->getItemTable()->selectWith($select);
     foreach ($items as $item) {
         $order->addItem($item);
     }
     $hydrator = new ClassMethods();
     $hydrator->addStrategy('items', new OrdersItemsHydratorStrategy(new ClassMethods()));
     $order->setClient($hydrator->extract($client));
     $order->setPtype($hydrator->extract($ptype));
     $order->setUser($hydrator->extract($user));
     $result = $hydrator->extract($order);
     unset($result['client_id']);
     unset($result['ptype_id']);
     unset($result['user_id']);
     unset($result['user']['username']);
     unset($result['user']['password']);
     return $result;
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $inputFile = new SplFileInfo($input->getArgument('input'));
     $tag = $inputFile->getMetadata()->getId3v1Tag();
     $hydrator = new ClassMethods();
     $data = $hydrator->extract($tag);
     $data['audio_properties'] = $hydrator->extract($data['audio_properties']);
     foreach (array_keys($data) as $name) {
         if (null === $data[$name]) {
             unset($data[$name]);
         }
     }
     $format = $input->getOption('format');
     if (!in_array($format, array(self::FORMAT_YAML))) {
         $format = self::FORMAT_YAML;
     }
     switch ($format) {
         case self::FORMAT_YAML:
             $data = Yaml::dump($data);
             break;
     }
     $outputFilename = $input->getArgument('output');
     if (null === $outputFilename) {
         $output->writeln('<info>' . $data . '</info>');
         return;
     }
     if (file_put_contents($outputFilename, $data)) {
         $output->writeln(sprintf('<info>Metadata file \'%s\' successfully exported.</info>', $outputFilename));
         return;
     }
     $output->writeln(sprintf('<error>Unable to write metadata file \'%s\'.</error>', $outputFilename));
 }
 public function extract($items)
 {
     $data = [];
     foreach ($items as $item) {
         $data[] = $this->hydrator->extract($item);
     }
     return $data;
 }
Beispiel #4
0
 public function extract($object)
 {
     $classMethods = new ClassMethods();
     $properties = $classMethods->extract($object);
     unset($properties['alternative']);
     return $properties;
 }
 public function extract($object)
 {
     $values = parent::extract($object);
     unset($values['arrayCopy']);
     // remove if null
     return array_filter($values);
 }
Beispiel #6
0
 public function saveVideo(VideosEntity $ent)
 {
     $hydrator = new ClassMethods();
     $data = $hydrator->extract($ent);
     $select = $this->sql->select();
     $whereArr = array('video_id' => $ent->getVideoId());
     $select->where($whereArr);
     $statement = $this->sql->prepareStatementForSqlObject($select);
     $results = $statement->execute();
     $result = false;
     if ($results->count() == 0) {
         // insert action
         $action = $this->sql->insert();
         $action->values($data);
         $statement = $this->sql->prepareStatementForSqlObject($action);
         $result = $statement->execute();
     } elseif (false && $results->count() > 0) {
         // update action
         $action = $this->sql->update();
         unset($data['id']);
         $action->set($data);
         $action->where(array('video_id' => $ent->getVideoId()));
     }
     return $result;
 }
Beispiel #7
0
 public function toArray()
 {
     $hydrator = new Hydrator\ClassMethods();
     $hydrator->setUnderscoreSeparatedKeys(false);
     $res = $hydrator->extract($this);
     return $res;
 }
 /**
  * Extract values from an object
  *
  * @param object $object 
  * @return array
  * @throws \Exception
  */
 public function extract($object)
 {
     if (!in_array('ShoppingCart\\Entity\\ShoppingCartEntityInterface', class_implements($object))) {
         throw new \Exception('$object must implement ShoppingCart\\Entity\\ShoppingCartEntityInterface');
     }
     $data = parent::extract($object);
     return $data;
 }
 /**
  * Converts the given value so that it can be extracted by the hydrator.
  *
  * @param mixed $value The original value.
  * @return mixed Returns the value that should be extracted.
  */
 public function extract($value)
 {
     if (!$value instanceof AddressEntity) {
         throw new \InvalidArgumentException("Invalid address.");
     }
     $hydrator = new ClassMethods(false);
     return $hydrator->extract($value);
 }
Beispiel #10
0
 public function extract($object)
 {
     if (!$object instanceof SubstanceInterface) {
         throw new \InvalidArgumentException('$object must be an instance of ' . __NAMESPACE__ . '\\SubstanceInterface');
     }
     $data = parent::extract($object);
     return $data;
 }
Beispiel #11
0
 public function extract($object)
 {
     if (!$object instanceof ProjectInterface) {
         throw new \InvalidArgumentException('$object must be an instance of Application\\Model\\Project\\ProjectInterface');
     }
     $data = parent::extract($object);
     return $data;
 }
 /**
  * Converts the given value so that it can be extracted by the hydrator.
  *
  * @param mixed $value The original value.
  * @return mixed Returns the value that should be extracted.
  */
 public function extract($value)
 {
     if (!$value instanceof PlanEntity) {
         throw new \InvalidArgumentException('The given value must be a Plan instance.');
     }
     $hydrator = new ClassMethods(true);
     return $hydrator->extract($value);
 }
 public function toArray()
 {
     $hydrator = new ClassMethods();
     $data = $hydrator->extract($this);
     $data['perfil'] = $data['usuario']->getGrupo()->getId();
     $data['login'] = $data['usuario']->getLogin();
     return $data;
 }
 /**
  * @param User $user
  */
 public function update(User $user)
 {
     $mapper = $this->getUserMapper();
     $mapper->update($user);
     $fresh = $mapper->get($user->getId());
     $hydrator = new ClassMethods();
     $hydrator->hydrate($hydrator->extract($fresh), $user);
 }
Beispiel #15
0
 public function extract($object)
 {
     if (!$object instanceof LocationInterface) {
         throw new \InvalidArgumentException('$object must be an instance of ' . __NAMESPACE__ . '\\LocationInterface');
     }
     $data = parent::extract($object);
     unset($data['full_address']);
     return $data;
 }
 public function saveTwitterUser(TwitterUserEntity $twitterUser, $setFoodtruck = false)
 {
     $hydrator = new ClassMethods();
     $data = $hydrator->extract($twitterUser);
     $select = $this->sql->select();
     //$whereArr = array('screen_name' => $twitterUser->getScreenName());
     $whereArr = array('twitter_id' => $twitterUser->getTwitterId());
     $select->where($whereArr);
     $statement = $this->sql->prepareStatementForSqlObject($select);
     echo "<br><br>" . $select->getSqlString($this->dbAdapter->getPlatform());
     $results = $statement->execute();
     //echo "\n".$results->count()."\n";
     //$results->current();
     if ($results->count() > 0) {
         // update action
         $action = $this->sql->update();
         $rows = new ResultSet();
         $arr = $rows->initialize($results)->toArray();
         $isFoodtruck = (int) $arr[0]['foodtruck'];
         if ($setFoodtruck == false) {
             unset($data['foodtruck']);
         }
         $action->set($data);
         $action->where(array('screen_name' => $twitterUser->getScreenName()));
         $data['foodtruck'] = $isFoodtruck;
     } else {
         // insert action
         $action = $this->sql->insert();
         $action->values($data);
     }
     $statement = $this->sql->prepareStatementForSqlObject($action);
     echo "<br><br>\n" . $action->getSqlString($this->dbAdapter->getPlatform()) . "\n";
     $result = $statement->execute();
     // save profile pic to blvd users
     // TODO use $results to see if profile image url is already set in db
     // TODO dont' iterate over blvdEntity
     // TODO use service locator to get BlvdMapper
     $blvdMapper = new BlvdMapper($this->dbAdapter);
     //this needs to be done manually as instagram may have added them already
     if ($blvdMapper->getBlvdWithTwitterUsername($twitterUser->getScreenName()) == false) {
         $blvdMapper->saveTwitterUserToBlvd($twitterUser);
     }
     if ($twitterUser->getProfileImageUrl() != '') {
         if ($blvdEntity = $blvdMapper->getBlvdWithTwitterUsername($twitterUser->getScreenName())) {
             foreach ($blvdEntity as $key => $ent) {
                 $ent->setProfilePictureUrl($twitterUser->getProfileImageUrl());
                 $blvdMapper->saveBlvd($ent);
                 break;
             }
         }
     }
     $hydrator = new ClassMethods();
     $twitterUser = new TwitterUserEntity();
     $hydrator->hydrate($data, $twitterUser);
     return $twitterUser;
     return $result;
 }
 /**
  * Extract values from an object
  *
  * @param  object $object
  * @return array
  * @throws Exception\InvalidArgumentException
  */
 public function extract($object)
 {
     if (!$object instanceof CountryEntityInterface) {
         throw new Exception\InvalidArgumentException('$object must be an instance of DelCountriesFlags\\Entity\\CountryInterface');
     }
     /* @var $object CountryInterface*/
     $data = parent::extract($object);
     return $data;
 }
Beispiel #18
0
 public function extract($object)
 {
     if (!$object instanceof CustomerInterface) {
         throw new \InvalidArgumentException('$object must be an instance of ' . __NAMESPACE__ . '\\CustomerInterface');
     }
     $data = parent::extract($object);
     $data['head_office_address_id'] = 0;
     return $data;
 }
Beispiel #19
0
 /**
  * Extract values from an object
  *
  * @param  UserEntity $object
  * @return array
  * @throws Exception\InvalidArgumentException
  */
 public function extract($object)
 {
     $this->guardUserObject($object);
     $data = parent::extract($object);
     if ($data['id'] === null) {
         unset($data['id']);
     }
     return $data;
 }
Beispiel #20
0
 public function extact($object)
 {
     $data = parent::extract($object);
     unset($data['password']);
     unset($data['deleted']);
     unset($data['activationKey']);
     unset($data['activated']);
     return $data;
 }
Beispiel #21
0
 public function extract($object)
 {
     if (!$object instanceof StaffInterface) {
         throw new Exception\InvalidArgumentException('$object must be an instance of Nickel\\Model\\Staff\\StaffInterface');
     }
     $data = parent::extract($object);
     unset($data['full_name']);
     return $data;
 }
Beispiel #22
0
 /**
  * {@inheritdoc}
  */
 public function jsonSerialize()
 {
     $hydrator = new ClassMethods(false);
     $data = $hydrator->extract($this);
     foreach ($data['datasets'] as $key => $value) {
         $data['datasets'][$key] = $value->jsonSerialize();
     }
     return $data;
 }
 /**
  * Extract values from an object
  *
  * @param  object $object
  * @return array
  * @throws Exception\InvalidArgumentException
  */
 public function extract($object)
 {
     if (!$object instanceof LoggerEntity) {
         throw new Exception\InvalidArgumentException('$object must be an instance of Logger\\Entity\\Logger');
     }
     /* @var $object UserInterface*/
     $data = parent::extract($object);
     return $data;
 }
Beispiel #24
0
 public function save(VendaItemEntity $entity)
 {
     $classMethods = new ClassMethods();
     $data = $classMethods->extract($entity);
     $action = $this->sql->insert();
     $action->values($data);
     $stmt = $this->sql->prepareStatementForSqlObject($action);
     $result = $stmt->execute();
     return (bool) $result->getAffectedRows();
 }
 /**
  * Extract values from an object
  *
  * @param  object $object
  * @return array
  * @throws Exception\InvalidArgumentException
  */
 public function extract($object)
 {
     if (!$object instanceof ModuleEntityInterface) {
         throw new Exception\InvalidArgumentException('$object must be an instance of Application\\Entity\\ModuleEntityInterface');
     }
     /* @var $object UserInterface*/
     $data = parent::extract($object);
     $data = $this->mapField('id', 'module_id', $data);
     return $data;
 }
Beispiel #26
0
 public function extract($object)
 {
     if (!$object instanceof ActivityInterface) {
         throw new InvalidArgumentException('$object must be an instance of ' . __NAMESPACE__ . '\\ActivityInterface');
     }
     $data = parent::extract($object);
     unset($data['risk']);
     unset($data['final_risk']);
     return $data;
 }
Beispiel #27
0
 /**
  * Extract values from an object
  *
  * @param  object $object
  * @return array
  * @throws Exception\InvalidArgumentException
  */
 public function extract($object)
 {
     if (!$object instanceof OptionEntityInterface) {
         throw new Exception\InvalidArgumentException('$object must be an instance of Breaker\\Entity\\OptionInterface');
     }
     /* @var $object OptionInterface*/
     $data = parent::extract($object);
     $data = $this->mapField('id', 'idoption', $data);
     return $data;
 }
Beispiel #28
0
 /**
  * Extract values from an object
  *
  * @param  object $object
  * @return array
  * @throws Exception\InvalidArgumentException
  */
 public function extract($object)
 {
     if (!$object instanceof UserEntityInterface) {
         throw new Exception\InvalidArgumentException('$object must be an instance of ZfcUser\\Entity\\UserInterface');
     }
     /* @var $object UserInterface */
     $data = parent::extract($object);
     $data = $this->mapField('id', 'user_id', $data);
     $data['roles'] = serialize($data['roles']);
     return $data;
 }
Beispiel #29
0
 /**
  * Extract values from an object
  *
  * @param  object $object
  * @return array
  * @throws Exception\InvalidArgumentException
  */
 public function extract($object)
 {
     if (!$object instanceof BreakerEntityInterface) {
         //throw new Exception\InvalidArgumentException('$object must be an instance of Acl\Entity\UserInterface');
         throw new RuntimeException('$object must be an instance of Project\\Entity\\ProjectInterface');
     }
     /* @var $object UserInterface*/
     $data = parent::extract($object);
     //         $data = $this->mapField('id', 'user_id', $data);
     return $data;
 }
Beispiel #30
0
 public function extract($object)
 {
     if (!$object instanceof ActivityInterface) {
         throw new Exception\InvalidArgumentException('$object must be an instance of Cobalt\\Model\\Activity\\ActivityInterface');
     }
     $data = parent::extract($object);
     if ($data['activity_time']) {
         $data['activity_time'] = $data['activity_time']->format('Y-m-d H:i:s');
     }
     return $data;
 }