コード例 #1
0
ファイル: SqlExecute.php プロジェクト: virusvn/fusio
 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, $configuration->get('sql'));
         $connection->executeUpdate($sql, $this->templateParser->getSqlParameters());
         return new Response(200, [], array('success' => true, 'message' => 'Execution was successful'));
     } else {
         throw new ConfigurationException('Given connection must be an DBAL connection');
     }
 }
コード例 #2
0
ファイル: BeanstalkPush.php プロジェクト: virusvn/fusio
 public function handle(Request $request, Parameters $configuration, Context $context)
 {
     $connection = $this->connector->getConnection($configuration->get('connection'));
     if ($connection instanceof Pheanstalk) {
         $writer = new Writer\Json();
         $body = $writer->write($request->getBody());
         $connection->useTube($configuration->get('queue'))->put($body);
         return new Response(200, [], array('success' => true, 'message' => 'Push was successful'));
     } else {
         throw new ConfigurationException('Given connection must be an Beanstalk connection');
     }
 }
コード例 #3
0
ファイル: SqlFetchAll.php プロジェクト: saakaifoundry/fusio
 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');
     }
 }
コード例 #4
0
ファイル: RabbitMqPush.php プロジェクト: virusvn/fusio
 public function handle(Request $request, Parameters $configuration, Context $context)
 {
     $connection = $this->connector->getConnection($configuration->get('connection'));
     if ($connection instanceof AMQPStreamConnection) {
         $writer = new Writer\Json();
         $body = $writer->write($request->getBody());
         $message = new AMQPMessage($body, array('content_type' => $writer->getContentType(), 'delivery_mode' => 2));
         $channel = $connection->channel();
         $channel->basic_publish($message, '', $configuration->get('queue'));
         return new Response(200, [], array('success' => true, 'message' => 'Push was successful'));
     } else {
         throw new ConfigurationException('Given connection must be an AMQP connection');
     }
 }
コード例 #5
0
ファイル: SqlFetchRow.php プロジェクト: saakaifoundry/fusio
 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');
     }
 }