예제 #1
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;
     }
 }
예제 #2
0
파일: Processor.php 프로젝트: uqiauto/fusio
 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;
     }
 }