Esempio n. 1
0
 /**
  * Get data from the validator
  * @return array
  */
 public function performValidation()
 {
     /**
      * check if the request has children needing validation
      **/
     $validationMessages = array();
     foreach ($this->request->toArray() as $key => $value) {
         if ($value instanceof ObjectArray) {
             /**
              * Loop through the array element validating any children
              * That are objects which implement RequestInterface
              */
             foreach ($value as $pos => $arrayValue) {
                 if ($arrayValue instanceof RequestInterface) {
                     $tmpData = $this->validateChild($arrayValue);
                     $validationMessages = array_merge($validationMessages, $tmpData);
                 }
             }
         } elseif ($value instanceof RequestInterface) {
             $tmpData = $this->validateChild($value);
             $validationMessages = array_merge($validationMessages, $tmpData);
         }
     }
     if (!$this->validator->validate($this->request)) {
         $parentValidation = $this->stripSiriusMessageObjects($this->validator->getMessages(), $this->request);
         $validationMessages = array_merge($validationMessages, $parentValidation);
     }
     $objectValidation = $this->request->customValidation();
     if (!empty($objectValidation)) {
         $validationMessages = array_merge($validationMessages, $objectValidation);
     }
     return $validationMessages;
 }
Esempio n. 2
0
 /**
  * The method by which the object is visited and is serialized
  * @param RequestInterface $object
  * @param Serializer $serializer
  * @return array Returns a formatted string such as json, post data from the object
  * @throws \Upg\Library\AbstractException Should throw exception if there is an error
  */
 public function visit(RequestInterface $object, Serializer $serializer)
 {
     $data = $object->getSerializerData();
     $data = $this->checkSerializeArray($data, $serializer);
     /**
      * Do not serialize the whole data instead return it as an array
      */
     return $data;
 }
Esempio n. 3
0
 /**
  * Serialize an object with the appropriate visitor
  * @param RequestInterface $object
  * @return string
  * @throws \Upg\Library\AbstractException Should throw exception if there is an error
  */
 public function serialize(RequestInterface $object)
 {
     if (array_key_exists($object->getSerialiseType(), $this->visitors)) {
         $visitor = $this->visitors[$object->getSerialiseType()];
         return $visitor->visit($object, $this);
     } else {
         throw new VisitorCouldNotBeFound($object->getSerialiseType(), $object);
     }
 }
Esempio n. 4
0
 /**
  * The method by which the object is visited and is serialized
  * @param RequestInterface $object
  * @param Serializer $serializer
  * @return string Returns a formatted string such as json, post data from the object
  * @throws \Upg\Library\AbstractException Should throw exception if there is an error
  */
 public function visit(RequestInterface $object, Serializer $serializer)
 {
     $data = $object->getSerializerData();
     $data = $this->checkSerializeArray($data, $serializer);
     return http_build_query($data);
 }
Esempio n. 5
0
 /**
  * The method by which the object is visited and is serialized
  * @param RequestInterface $object
  * @param Serializer $serializer
  * @return string Returns a formatted string such as json, post data from the object
  * @throws \Upg\Library\AbstractException Should throw exception if there is an error
  */
 public function visit(RequestInterface $object, Serializer $serializer)
 {
     $data = $object->getSerializerData();
     $data = $this->checkSerializeArray($data, $serializer);
     return json_encode($data);
 }