public function handle(RequestInterface $request, ParametersInterface $configuration, ContextInterface $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); } }
/** * @param integer $actionId * @param \Fusio\Engine\RequestInterface $request * @param \Fusio\Engine\ContextInterface $context * @return \Fusio\Engine\ResponseInterface */ public function execute($actionId, RequestInterface $request, ContextInterface $context) { $repository = $this->getCurrentRepository(); $action = $repository->get($actionId); if ($action instanceof Model\ActionInterface) { $parameters = new Parameters($action->getConfig()); return $this->factory->factory($action->getClass())->handle($request, $parameters, $context->withAction($action)); } else { throw new RuntimeException('Could not found action ' . $actionId); } }
/** * @param integer $actionId * @param \Fusio\Engine\RequestInterface $request * @param \Fusio\Engine\ContextInterface $context * @return \Fusio\Engine\ResponseInterface */ public function execute($actionId, RequestInterface $request, ContextInterface $context) { $repository = end($this->stack); $action = $repository->getAction($actionId); if ($action instanceof ActionInterface) { $parameters = new Parameters($action->getConfig()); return $this->factory->factory($action->getClass())->handle($request, $parameters, $context->withAction($action)); } else { throw new ConfigurationException('Could not found action ' . $actionId); } }
public function handle(RequestInterface $request, ParametersInterface $configuration, ContextInterface $context) { $connection = $this->connector->getConnection($configuration->get('connection')); if ($connection instanceof Connection) { // parse sql $parser = $this->templateFactory->newSqlParser(); $sql = $parser->parse($request, $context->withConnection($connection), $configuration->get('sql')); $connection->executeUpdate($sql, $parser->getSqlParameters()); return $this->response->build(200, [], array('success' => true, 'message' => 'Execution was successful')); } else { throw new ConfigurationException('Given connection must be an DBAL connection'); } }
public function handle(RequestInterface $request, ParametersInterface $configuration, ContextInterface $context) { $connection = $this->connector->getConnection($configuration->get('connection')); if ($connection instanceof Connection) { // parse sql $parser = $this->templateFactory->newSqlParser(); $sql = $parser->parse($request, $context->withConnection($connection), $configuration->get('sql')); $result = $connection->fetchAll($sql, $parser->getSqlParameters()); $key = $configuration->get('propertyName') ?: 'entry'; return $this->response->build(200, [], [$key => CurveArray::nest($result)]); } else { throw new ConfigurationException('Given connection must be a DBAL connection'); } }
public function handle(RequestInterface $request, ParametersInterface $configuration, ContextInterface $context) { $connection = $this->connector->getConnection($configuration->get('connection')); if ($connection instanceof Connection) { // parse sql $parser = $this->templateFactory->newSqlParser(); $sql = $parser->parse($request, $context->withConnection($connection), $configuration->get('sql')); $result = $connection->fetchAssoc($sql, $parser->getSqlParameters()); if (empty($result)) { throw new StatusCode\NotFoundException('Entry not available'); } return $this->response->build(200, [], CurveArray::nest($result)); } else { throw new ConfigurationException('Given connection must be an DBAL connection'); } }