Esempio n. 1
0
 protected function getContext()
 {
     $app = new App();
     $app->setAnonymous(false);
     $app->setId(2);
     $app->setUserId(2);
     $app->setStatus(1);
     $app->setName('Foo-App');
     $app->setUrl('http://google.com');
     $app->setAppKey('5347307d-d801-4075-9aaa-a21a29a448c5');
     $action = new Action();
     $action->setId(uniqid());
     $action->setName('foo');
     $action->setDate(date('Y-m-d H:i:s'));
     return new Context(34, $app, $action);
 }
Esempio n. 2
0
 public function getAction($actionId)
 {
     if (is_numeric($actionId)) {
         $column = 'id';
     } else {
         $column = 'name';
     }
     $sql = 'SELECT id, 
                    name, 
                    class, 
                    config, 
                    date 
               FROM fusio_action 
              WHERE ' . $column . ' = :id';
     $row = $this->connection->fetchAssoc($sql, array('id' => $actionId));
     if (!empty($row)) {
         $config = !empty($row['config']) ? unserialize($row['config']) : array();
         $action = new Action();
         $action->setId($row['id']);
         $action->setName($row['name']);
         $action->setClass($row['class']);
         $action->setConfig($config);
         $action->setDate($row['date']);
         return $action;
     } else {
         return null;
     }
 }
Esempio n. 3
0
 public function handle(RequestInterface $request, ParametersInterface $configuration, ContextInterface $context)
 {
     $yaml = new Parser();
     $process = $yaml->parse($configuration->get('process'));
     $repository = new MemoryRepository();
     $id = 1;
     if (is_array($process)) {
         foreach ($process as $class => $config) {
             if (is_array($config)) {
                 $config = array_map('strval', $config);
                 if (isset($config['id'])) {
                     $name = $config['id'];
                     unset($config['id']);
                 } else {
                     $name = 'action-' . $id;
                 }
                 $action = new Action();
                 $action->setId($id);
                 $action->setName($name);
                 $action->setClass($class);
                 $action->setConfig($config);
                 $action->setDate(date('Y-m-d H:i:s'));
                 $repository->add($action);
                 $id++;
             }
         }
     }
     if ($id === 1) {
         throw new ConfigurationException('No process defined');
     }
     $this->processor->push($repository);
     try {
         $return = $this->processor->execute(1, $request, $context);
         $this->processor->pop();
         return $return;
     } catch (\Exception $e) {
         $this->processor->pop();
         throw $e;
     }
 }