execute() public method

public execute ( Lisphp_Scope $scope )
$scope Lisphp_Scope
Ejemplo n.º 1
0
 public function testFromFile()
 {
     $testFiles = glob(__DIR__ . '/Functional/*.lisphp');
     foreach ($testFiles as $file) {
         $code = file_get_contents($file);
         $scope = Lisphp_Environment::workflow();
         $program = new Lisphp_Program($code);
         $result = $program->execute($scope);
         $expected = file_get_contents(preg_replace('/\\.lisphp$/', '.out', $file));
         $this->assertSame(trim($expected), trim($result));
     }
 }
Ejemplo n.º 2
0
 /**
  * @return \Phalcon\Http\ResponseInterface|string|void
  */
 public function resultAction()
 {
     $hash_id = $this->request->getQuery('id', 'string', '');
     $workflow = $this->workflow->findFirst($hash_id, $this->current_user->id);
     if ($workflow) {
         // delete old result
         $result = WorkflowResult::findByWf_id($workflow->id);
         $result->delete();
         // set globals var
         $GLOBALS['workflow_id'] = $workflow->id;
         $GLOBALS['user_id'] = $this->current_user->id;
         $var_code = '';
         $var = WorkflowVar::findByWf_id($workflow->id);
         foreach ($var as $item) {
             if (is_string($item->value)) {
                 $var_code .= sprintf('(define %s "%s")', $item->name, str_replace('"', '\\"', $item->value));
             } else {
                 $var_code .= sprintf('(define %s %s)', $item->name, $item->value);
             }
         }
         // run code
         try {
             $env = Lisphp_Environment::workflow();
             $program = new Lisphp_Program($var_code . $workflow->code_snippets);
             $code_result = $program->execute($env);
         } catch (Exception $e) {
             $code_result = $e->getMessage();
         }
         // active
         UserActive::record('workflow-run', $this->current_user->id);
         // unset globals var
         unset($GLOBALS['workflow_id']);
         // new result
         $workflow_result = WorkflowResult::findByWf_id($workflow->id);
         $this->view->setVar('title', $workflow->title);
         $this->view->setVar('code_result', $code_result);
         $this->view->setVar('workflow_result', $workflow_result);
         return $this->view->partial('workflow/result');
     } else {
         return $this->response->redirect('workflow/lists');
     }
 }