Exemplo n.º 1
0
 /**
  * @return \Fusio\Engine\Repository\ActionInterface
  */
 protected function createRepository()
 {
     $action = new Action();
     $action->setId(1);
     $action->setName('foo');
     $action->setClass('\\stdClass');
     $repository = new Repository\ActionMemory();
     $repository->add($action);
     return $repository;
 }
Exemplo n.º 2
0
 protected function getRepository()
 {
     $repository = $this->getActionRepository();
     $action = new Action();
     $action->setId(1);
     $action->setName('foo');
     $action->setClass(CallbackAction::class);
     $action->setConfig(['callback' => function (Response\FactoryInterface $response) {
         return $response->build(200, [], ['foo' => 'bar']);
     }]);
     $repository->add($action);
     return $repository;
 }
Exemplo n.º 3
0
 protected function newAction(array $row)
 {
     $config = !empty($row['config']) ? unserialize($row['config']) : [];
     $action = new Action();
     $action->setId($row['id']);
     $action->setName($row['name']);
     $action->setClass($row['class']);
     $action->setConfig($config);
     $action->setDate($row['date']);
     return $action;
 }
Exemplo n.º 4
0
 /**
  * @return \Fusio\Engine\Context
  */
 protected function getContext()
 {
     $app = new App();
     $app->setAnonymous(false);
     $app->setId(3);
     $app->setUserId(2);
     $app->setStatus(1);
     $app->setName('Foo-App');
     $app->setUrl('http://google.com');
     $app->setParameters(['foo' => 'bar']);
     $app->setScopes(['foo', 'bar']);
     $app->setAppKey('5347307d-d801-4075-9aaa-a21a29a448c5');
     $user = new User();
     $user->setAnonymous(false);
     $user->setId(2);
     $user->setStatus(0);
     $user->setName('Consumer');
     $action = new Action();
     $action->setId(uniqid());
     $action->setName('foo');
     $action->setDate(date('Y-m-d H:i:s'));
     return new Context(34, $app, $user, $action);
 }
Exemplo n.º 5
0
 protected function buildRepository($actionId, Repository\ActionInterface $repository)
 {
     $action = $this->actionTable->get($actionId);
     $config = $action->config;
     $form = $this->actionParser->getForm($action->class);
     if ($form instanceof Form\Container) {
         $elements = $form->getElements();
         foreach ($elements as $element) {
             if ($element instanceof Form\Element\Action) {
                 $name = $element->getName();
                 if (isset($config[$name]) && $config[$name] > 0) {
                     $this->buildRepository($config[$name], $repository);
                 }
             }
         }
     }
     $entry = new Model\Action();
     $entry->setId($action['id']);
     $entry->setName($action['name']);
     $entry->setClass($action['class']);
     $entry->setConfig($action['config']);
     $entry->setDate($action['date']->format('Y-m-d H:i:s'));
     $repository->add($entry);
 }