/** * フレームワークを起動させる * * @access public * @since 3.0.0 */ public function execute() { $this->log->debug("************** controller#execute called."); // デフォルトトランザクションをコンテナに登録 $defaultTx = $this->txManager->getTransaction(); $this->container->register('DefaultTx', $defaultTx); // 実行するActionを決定 $actionName = $this->hook->makeActionName(); if ($actionName == NULL) { throw new Teeple_Exception("アクションが特定できません。"); } // 初期ActionをActionChainにセット $this->log->debug("****actionName: {$actionName}"); try { $this->actionChain->add($actionName); } catch (Exception $e) { $this->log->warn($e->getMessage()); $isContinue = $this->hook->actionClassNotFound($actionName); if (!$isContinue) { return; } } // FilterChainのセットアップと実行 $this->filterChain->build(); $this->filterChain->execute(); //$this->filterChain->clear(); }
private function createActionTemplate($actionName) { $this->log->debug("Actionクラスの雛形を作成します。"); list($className, $classfile, $templatefile) = $this->makeNames($actionName); $renderer = new Smarty(); $renderer->template_dir = VIEW_TEMPLATE_DIR; $renderer->compile_dir = VIEW_COMPILE_DIR; $renderer->assign('className', $className); $renderer->assign('actionName', $actionName); $renderer->assign('templatefile', $templatefile); if (!@file_exists($classfile)) { $result = $renderer->fetch('devhelper/template/Action.class.php.txt'); if (!$this->fileutil->write($classfile, $result)) { print "Actionクラスの自動生成に失敗しました。ファイルが作成できません。"; return; } } if (!@file_exists($templatefile)) { $result = $renderer->fetch('devhelper/template/template.html'); if (!$this->fileutil->write($templatefile, $result)) { print "HTMLの自動生成に失敗しました。ファイルが作成できません。"; return; } } print "Actionクラスを自動生成しました。{$classfile} <br/>"; $this->actionChain->add($actionName); return; }
public function testValidation() { $this->request->setParameter('str1', 'test'); $this->request->setParameter('str2', 'てすとです。ほげほげ'); $this->request->setActionMethod("doLogin"); $this->actionChain->add('teeple_test_action'); $this->actionChain->execute(); $errors = $this->request->getAllErrorMessages(); $this->assertEqual(2, count($errors)); $this->assertEqual("値1は10文字以上5文字以下で入力してください。", $errors[0]); $this->assertEqual("文字列2の長さが間違ってるで。", $errors[1]); $this->assertEqual("result/validateError", $this->response->getView()); // executeメソッドにはValidationは実行されない。 $this->actionChain->clear(); $this->actionChain->add('teeple_test_action'); $this->request->setActionMethod('execute'); $this->request->resetErrorMessages(); $this->request->setFilterError(NULL); $this->actionChain->execute(); $errors = $this->request->getAllErrorMessages(); $this->assertEqual(0, count($errors)); $this->assertEqual('result/execute', $this->response->getView()); }