Ejemplo n.º 1
0
Archivo: Form.php Proyecto: seytar/psx
 public function read(MessageInterface $message)
 {
     $body = (string) $message->getBody();
     $form = array();
     if (!empty($body)) {
         parse_str($body, $form);
         return CurveArray::objectify($form);
     } else {
         return null;
     }
 }
Ejemplo n.º 2
0
 public function handle(Request $request, Parameters $configuration, Context $context)
 {
     $connection = $this->connector->getConnection($configuration->get('connection'));
     if ($connection instanceof Connection) {
         // parse sql
         $sql = $this->templateParser->parse($request, $configuration, $context->withConnection($connection), $configuration->get('sql'));
         $result = $connection->fetchAll($sql, $this->templateParser->getSqlParameters());
         $key = $configuration->get('propertyName') ?: 'entry';
         return new Response(200, [], [$key => CurveArray::nest($result)]);
     } else {
         throw new ConfigurationException('Given connection must be a DBAL connection');
     }
 }
Ejemplo n.º 3
0
 public function handle(Request $request, Parameters $configuration, Context $context)
 {
     $connection = $this->connector->getConnection($configuration->get('connection'));
     if ($connection instanceof Connection) {
         // parse sql
         $sql = $this->templateParser->parse($request, $configuration, $context->withConnection($connection), $configuration->get('sql'));
         $result = $connection->fetchAssoc($sql, $this->templateParser->getSqlParameters());
         if (empty($result)) {
             throw new StatusCode\NotFoundException('Entry not available');
         }
         return new Response(200, [], CurveArray::nest($result));
     } else {
         throw new ConfigurationException('Given connection must be an DBAL connection');
     }
 }
Ejemplo n.º 4
0
 public static function isObject($value)
 {
     return $value instanceof RecordInterface || $value instanceof \stdClass || is_array($value) && CurveArray::isAssoc($value);
 }