예제 #1
0
파일: Filter.php 프로젝트: miztaka/teeple2
 /**
  * Filterの処理を実行します。
  *
  */
 public function execute()
 {
     $clsname = get_class($this);
     // 現在のアクション名を取得
     $actionName = $this->actionChain->getCurActionName();
     // 実行対象かどうかのチェック
     $isTarget = $this->isTarget($actionName);
     if (!$isTarget) {
         $this->log->info("{$clsname} は実行対象外のためスキップします。");
     }
     // prefilterを実行
     if ($isTarget) {
         $this->log->debug("{$clsname}のprefilterを実行します。");
         $this->prefilter();
         $this->log->debug("{$clsname}のprefilterを実行しました。");
     }
     // filterChain
     $this->filterChain->execute();
     // postfilterを実行
     if ($isTarget) {
         $this->log->debug("{$clsname}のpostfilterを実行します。");
         $this->postfilter();
         $this->log->debug("{$clsname}のpostfilterを実行しました。");
     }
     return;
 }
예제 #2
0
 /**
  * フレームワークを起動させる
  *
  * @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();
 }
예제 #3
0
 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;
 }
예제 #4
0
 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());
 }
예제 #5
0
 /**
  * 設定ファイルを読み込む
  *
  * @access  public
  * @since   3.0.0
  */
 function execute()
 {
     $this->readConfigFiles($this->actionChain->getCurActionName());
 }