Ejemplo n.º 1
0
 /**
  * Insert tree-structured array as nodes in XMLWriter
  * and end the current Document.
  *
  * @param $data Array - tree-structured array
  *
  * @throws \Genesis\Exceptions\InvalidArgument
  *
  * @return void
  */
 public function populateNodes($data)
 {
     if (!\Genesis\Utils\Common::isValidArray($data)) {
         throw new \Genesis\Exceptions\InvalidArgument('Invalid data structure');
     }
     // Ensure that the Array position is 0
     reset($data);
     $this->iterateArray(key($data), reset($data));
     // Finish the document
     $this->context->endDocument();
 }
Ejemplo n.º 2
0
 /**
  * Verify that transaction type parameters are populated correctly
  *
  * @param string $transactionType
  * @param array $parameters
  * @throws \Genesis\Exceptions\ErrorParameter
  */
 protected function verifyTransactionType($transactionType, $parameters = array())
 {
     if (!\Genesis\API\Constants\Transaction\Types::isValidTransactionType($transactionType)) {
         throw new \Genesis\Exceptions\ErrorParameter(sprintf('Transaction type (%s) is not valid', $transactionType));
     }
     $transactionCustomRequiredParams = \Genesis\API\Constants\Transaction\Types::getCustomRequiredParameters($transactionType);
     if (\Genesis\Utils\Common::isValidArray($transactionCustomRequiredParams)) {
         foreach ($transactionCustomRequiredParams as $customRequiredParam => $customRequiredParamValues) {
             if (!array_key_exists($customRequiredParam, $parameters)) {
                 foreach ($parameters as $parameter) {
                     if (!\Genesis\Utils\Common::isValidArray($parameter) || !array_key_exists($customRequiredParam, $parameter)) {
                         throw new \Genesis\Exceptions\ErrorParameter(sprintf('Empty (null) required parameter: %s for transaction type %s', $customRequiredParam, $transactionType));
                     }
                 }
             }
             if (!empty($customRequiredParamValues) && \Genesis\Utils\Common::isValidArray($customRequiredParamValues)) {
                 if (!\Genesis\Utils\Common::arrayContainsArrayItems($parameters)) {
                     if (!in_array($parameters[$customRequiredParam], $customRequiredParamValues)) {
                         sprintf('Invalid value (%s) for required parameter: %s (Transaction type: %s)', $parameters[$customRequiredParam], $customRequiredParam, $transactionType);
                     }
                 } else {
                     foreach ($parameters as $parameter) {
                         if (!in_array($parameter[$customRequiredParam], $customRequiredParamValues)) {
                             throw new \Genesis\Exceptions\ErrorParameter(sprintf('Invalid value (%s) for required parameter: %s (Transaction type: %s)', $parameter[$customRequiredParam], $customRequiredParam, $transactionType));
                         }
                     }
                 }
             }
         }
     }
 }