Skip to content

Commit

Permalink
use fusio engine and move to psr4 autoloader
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskapp committed Nov 5, 2015
1 parent 72f2a55 commit 8570b9b
Show file tree
Hide file tree
Showing 280 changed files with 2,348 additions and 2,238 deletions.
50 changes: 29 additions & 21 deletions src/Fusio/Action/BeanstalkPush.php → src/Action/BeanstalkPush.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

namespace Fusio\Action;
namespace Fusio\Impl\Action;

use Doctrine\DBAL\Connection;
use Fusio\ActionInterface;
use Fusio\ConfigurationException;
use Fusio\Connector;
use Fusio\Context;
use Fusio\Form;
use Fusio\Form\Element;
use Fusio\Parameters;
use Fusio\Request;
use Fusio\Response;
use Fusio\Engine\ActionInterface;
use Fusio\Engine\ContextInterface;
use Fusio\Engine\ConnectorInterface;
use Fusio\Engine\Form\BuilderInterface;
use Fusio\Engine\Form\ElementFactoryInterface;
use Fusio\Engine\RequestInterface;
use Fusio\Engine\Response\FactoryInterface as ResponseFactoryInterface;
use Fusio\Engine\ParametersInterface;
use Fusio\Impl\ConfigurationException;
use Pheanstalk\Pheanstalk;
use PSX\Data\Writer;

Expand All @@ -51,16 +51,22 @@ class BeanstalkPush implements ActionInterface

/**
* @Inject
* @var \Fusio\Connector
* @var \Fusio\Engine\ConnectorInterface
*/
protected $connector;

/**
* @Inject
* @var \Fusio\Engine\Response\FactoryInterface
*/
protected $response;

public function getName()
{
return 'Beanstalk-Push';
}

public function handle(Request $request, Parameters $configuration, Context $context)
public function handle(RequestInterface $request, ParametersInterface $configuration, ContextInterface $context)
{
$connection = $this->connector->getConnection($configuration->get('connection'));

Expand All @@ -70,31 +76,33 @@ public function handle(Request $request, Parameters $configuration, Context $con

$connection->useTube($configuration->get('queue'))->put($body);

return new Response(200, [], array(
return $this->response->build(200, [], [
'success' => true,
'message' => 'Push was successful'
));
]);
} else {
throw new ConfigurationException('Given connection must be an Beanstalk connection');
}
}

public function getForm()
public function configure(BuilderInterface $builder, ElementFactoryInterface $elementFactory)
{
$form = new Form\Container();
$form->add(new Element\Connection('connection', 'Connection', $this->connection, 'The Beanstalk connection which should be used'));
$form->add(new Element\Input('queue', 'Queue', 'text', 'The name of the queue'));

return $form;
$builder->add($elementFactory->newConnection('connection', 'Connection', 'The Beanstalk connection which should be used'));
$builder->add($elementFactory->newInput('queue', 'Queue', 'text', 'The name of the queue'));
}

public function setConnection(Connection $connection)
{
$this->connection = $connection;
}

public function setConnector(Connector $connector)
public function setConnector(ConnectorInterface $connector)
{
$this->connector = $connector;
}

public function setResponse(ResponseFactoryInterface $response)
{
$this->response = $response;
}
}
31 changes: 14 additions & 17 deletions src/Fusio/Action/CacheResponse.php → src/Action/CacheResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

namespace Fusio\Action;
namespace Fusio\Impl\Action;

use Doctrine\DBAL\Connection;
use Fusio\ActionInterface;
use Fusio\Context;
use Fusio\Form;
use Fusio\Form\Element;
use Fusio\Parameters;
use Fusio\Processor;
use Fusio\Request;
use Fusio\Engine\ActionInterface;
use Fusio\Engine\ContextInterface;
use Fusio\Engine\Form\BuilderInterface;
use Fusio\Engine\Form\ElementFactoryInterface;
use Fusio\Engine\ParametersInterface;
use Fusio\Engine\ProcessorInterface;
use Fusio\Engine\RequestInterface;
use PSX\Cache;

/**
Expand All @@ -48,7 +48,7 @@ class CacheResponse implements ActionInterface

/**
* @Inject
* @var \Fusio\Processor
* @var \Fusio\Engine\ProcessorInterface
*/
protected $processor;

Expand All @@ -63,7 +63,7 @@ public function getName()
return 'Cache-Response';
}

public function handle(Request $request, Parameters $configuration, Context $context)
public function handle(RequestInterface $request, ParametersInterface $configuration, ContextInterface $context)
{
$key = md5($configuration->get('action'));
$item = $this->cache->getItem($key);
Expand All @@ -81,21 +81,18 @@ public function handle(Request $request, Parameters $configuration, Context $con
return $response;
}

public function getForm()
public function configure(BuilderInterface $builder, ElementFactoryInterface $elementFactory)
{
$form = new Form\Container();
$form->add(new Element\Action('action', 'Action', $this->connection, 'The response of this action gets cached'));
$form->add(new Element\Input('expire', 'Expire', 'text', 'Number of seconds when the cache expires'));

return $form;
$builder->add($elementFactory->newAction('action', 'Action', 'The response of this action gets cached'));
$builder->add($elementFactory->newInput('expire', 'Expire', 'text', 'Number of seconds when the cache expires'));
}

public function setConnection(Connection $connection)
{
$this->connection = $connection;
}

public function setProcessor(Processor $processor)
public function setProcessor(ProcessorInterface $processor)
{
$this->processor = $processor;
}
Expand Down
31 changes: 14 additions & 17 deletions src/Fusio/Action/Composite.php → src/Action/Composite.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

namespace Fusio\Action;
namespace Fusio\Impl\Action;

use Doctrine\DBAL\Connection;
use Fusio\ActionInterface;
use Fusio\Context;
use Fusio\Form;
use Fusio\Form\Element;
use Fusio\Parameters;
use Fusio\Processor;
use Fusio\Request;
use Fusio\Engine\ActionInterface;
use Fusio\Engine\ContextInterface;
use Fusio\Engine\Form\BuilderInterface;
use Fusio\Engine\Form\ElementFactoryInterface;
use Fusio\Engine\ParametersInterface;
use Fusio\Engine\ProcessorInterface;
use Fusio\Engine\RequestInterface;

/**
* Composite
Expand All @@ -47,7 +47,7 @@ class Composite implements ActionInterface

/**
* @Inject
* @var \Fusio\Processor
* @var \Fusio\Engine\ProcessorInterface
*/
protected $processor;

Expand All @@ -56,28 +56,25 @@ public function getName()
return 'Composite';
}

public function handle(Request $request, Parameters $configuration, Context $context)
public function handle(RequestInterface $request, ParametersInterface $configuration, ContextInterface $context)
{
$this->processor->execute($configuration->get('in'), $request, $context);

return $this->processor->execute($configuration->get('out'), $request, $context);
}

public function getForm()
public function configure(BuilderInterface $builder, ElementFactoryInterface $elementFactory)
{
$form = new Form\Container();
$form->add(new Element\Action('in', 'In', $this->connection, 'The request will be redirected to this action'));
$form->add(new Element\Action('out', 'Out', $this->connection, 'The response of this action will be used as response'));

return $form;
$builder->add($elementFactory->newAction('in', 'In', 'The request will be redirected to this action'));
$builder->add($elementFactory->newAction('out', 'Out', 'The response of this action will be used as response'));
}

public function setConnection(Connection $connection)
{
$this->connection = $connection;
}

public function setProcessor(Processor $processor)
public function setProcessor(ProcessorInterface $processor)
{
$this->processor = $processor;
}
Expand Down
35 changes: 16 additions & 19 deletions src/Fusio/Action/Condition.php → src/Action/Condition.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

namespace Fusio\Action;
namespace Fusio\Impl\Action;

use Doctrine\DBAL\Connection;
use Fusio\ActionInterface;
use Fusio\App\RateLimit;
use Fusio\Context;
use Fusio\Form;
use Fusio\Form\Element;
use Fusio\Parameters;
use Fusio\Processor;
use Fusio\Request;
use Fusio\Engine\ActionInterface;
use Fusio\Engine\ContextInterface;
use Fusio\Engine\Form\BuilderInterface;
use Fusio\Engine\Form\ElementFactoryInterface;
use Fusio\Engine\ParametersInterface;
use Fusio\Engine\ProcessorInterface;
use Fusio\Engine\RequestInterface;
use Fusio\Impl\App\RateLimit;
use PSX\Cache;
use PSX\Data\Accessor;
use PSX\Validate;
Expand All @@ -54,7 +54,7 @@ class Condition implements ActionInterface, ParserCacheInterface

/**
* @Inject
* @var \Fusio\Processor
* @var \Fusio\Engine\ProcessorInterface
*/
protected $processor;

Expand All @@ -69,7 +69,7 @@ public function getName()
return 'Condition';
}

public function handle(Request $request, Parameters $configuration, Context $context)
public function handle(RequestInterface $request, ParametersInterface $configuration, ContextInterface $context)
{
$condition = $configuration->get('condition');
$language = new ExpressionLanguage($this);
Expand All @@ -89,14 +89,11 @@ public function handle(Request $request, Parameters $configuration, Context $con
}
}

public function getForm()
public function configure(BuilderInterface $builder, ElementFactoryInterface $elementFactory)
{
$form = new Form\Container();
$form->add(new Element\Input('condition', 'Condition', 'text', 'The condition which gets evaluated. You can access parameters from the context with i.e. <code>parameters.get("foo") == "bar"</code>. Click <a ng-click="help.showDialog(\'help/action/condition.md\')">here</a> for more informations about the syntax.'));
$form->add(new Element\Action('true', 'True', $this->connection, 'Executed if the condition evaluates to true'));
$form->add(new Element\Action('false', 'False', $this->connection, 'Executed if the condition evaluates to false'));

return $form;
$builder->add($elementFactory->newInput('condition', 'Condition', 'text', 'The condition which gets evaluated. You can access parameters from the context with i.e. <code>parameters.get("foo") == "bar"</code>. Click <a ng-click="help.showDialog(\'help/action/condition.md\')">here</a> for more informations about the syntax.'));
$builder->add($elementFactory->newAction('true', 'True', 'Executed if the condition evaluates to true'));
$builder->add($elementFactory->newAction('false', 'False', 'Executed if the condition evaluates to false'));
}

public function save($key, ParsedExpression $expression)
Expand All @@ -119,7 +116,7 @@ public function setConnection(Connection $connection)
$this->connection = $connection;
}

public function setProcessor(Processor $processor)
public function setProcessor(ProcessorInterface $processor)
{
$this->processor = $processor;
}
Expand Down
Loading

0 comments on commit 8570b9b

Please sign in to comment.