コード例 #1
0
ファイル: Condition.php プロジェクト: virusvn/fusio
 public function handle(Request $request, Parameters $configuration, Context $context)
 {
     $condition = $configuration->get('condition');
     $language = new ExpressionLanguage($this);
     $values = array('rateLimit' => new RateLimit($this->connection, $context), 'app' => $context->getApp(), 'routeId' => $context->getRouteId(), 'uriFragments' => $request->getUriFragments(), 'parameters' => $request->getParameters(), 'body' => new Accessor(new Validate(), $request->getBody()));
     if (!empty($condition) && $language->evaluate($condition, $values)) {
         return $this->processor->execute($configuration->get('true'), $request, $context);
     } else {
         return $this->processor->execute($configuration->get('false'), $request, $context);
     }
 }
コード例 #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
ファイル: 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');
     }
 }
コード例 #4
0
ファイル: Parser.php プロジェクト: virusvn/fusio
 public function parse(Request $request, Parameters $configuration, Context $context, $data)
 {
     $cacheKey = $configuration->get(Parameters::ACTION_ID);
     $lastModified = $configuration->get(Parameters::ACTION_LAST_MODIFIED);
     $this->loader->set($data, $cacheKey, $lastModified);
     $this->twig->getFilter(Prepare::FILTER_NAME)->getCallable()->clear();
     try {
         return $this->twig->render($configuration->get(Parameters::ACTION_ID), ['request' => $request, 'context' => $context, 'body' => new Accessor(new Validate(), $request->getBody())]);
     } catch (\Twig_Error_Runtime $e) {
         // if we have an display exception throw the original exception
         if ($e->getPrevious() instanceof DisplayException) {
             throw $e->getPrevious();
         } else {
             throw $e;
         }
     }
 }