OSDN Git Service

fixed: modifier of controller
authorSotaro KARASAWA <sotarok@users.sourceforge.jp>
Sat, 8 Jan 2011 16:20:06 +0000 (01:20 +0900)
committerSotaro KARASAWA <sotarok@users.sourceforge.jp>
Sat, 8 Jan 2011 16:20:06 +0000 (01:20 +0900)
class/Controller.php
skel/app.controller.php
test/Class_Test.php
test/Config_Test.php
test/Logger_Test.php
test/Plugin/Csrf/Plugin_Csrf_Session_Test.php
test/Plugin/Validator/Plugin_Validator_Strmaxcompat_Test.php
test/Plugin/Validator/Plugin_Validator_Strmincompat_Test.php
test/UnitTestBase.php

index 3183127..7cbb348 100644 (file)
@@ -73,10 +73,10 @@ class Ethna_Controller
     );
 
     /** @protected    array       クラス設定 */
-    protected $class = array();
+    public $class = array();
 
     /** @protected    array       クラス設定(デフォルト) */
-    protected $class_default = array(
+    public $class_default = array(
         'class'         => 'Ethna_ClassFactory',
         'backend'       => 'Ethna_Backend',
         'config'        => 'Ethna_Config',
@@ -523,6 +523,18 @@ class Ethna_Controller
         }
         return $this->directory[$key];
     }
+    /**
+     *  アプリケーションディレクトリ設定を返す
+     *
+     *  @access public
+     *  @param  string  $key    type
+     *  @return string  $key    directory
+     */
+    function setDirectory($key, $value)
+    {
+        $this->directory[$key] = $value;
+    }
+
 
     /**
      *  アプリケーション拡張子設定を返す
@@ -562,36 +574,70 @@ class Ethna_Controller
     }
 
     /**
-     *  アクションフォームオブジェクトのアクセサ
+     *  Accessor for ActionForm
      *
      *  @access public
      *  @return object  Ethna_ActionForm    アクションフォームオブジェクト
      */
-    function getActionForm()
+    public function getActionForm()
     {
         // 明示的にクラスファクトリを利用していない
         return $this->action_form;
     }
 
     /**
-     *  ビューオブジェクトのアクセサ
+     *  Setter for ActionForm
+     *  if the ::$action_form class is not null, then cannot set the view
+     *
+     *  @access public
+     *  @return object  Ethna_ActionForm    アクションフォームオブジェクト
+     */
+    public function setActionForm($af)
+    {
+        if ($this->action_form !== null) {
+            return false;
+        }
+        $this->action_form = $af;
+        return true;
+    }
+
+
+    /**
+     *  Accessor for ViewClass
      *
      *  @access public
      *  @return object  Ethna_View          ビューオブジェクト
      */
-    function getView()
+    public function getView()
     {
         // 明示的にクラスファクトリを利用していない
         return $this->view;
     }
 
     /**
+     *  Setter for ViewClass
+     *  if the ::$view class is not null, then cannot set the view
+     *
+     *  @access public
+     *  @param  $view object  Ethna_ViewClass
+     *  @return boolean
+     */
+    public function setView($view)
+    {
+        if ($this->view !== null) {
+            return false;
+        }
+        $this->view = $view;
+        return true;
+    }
+
+    /**
      *  backendオブジェクトのアクセサ
      *
      *  @access public
      *  @return object  Ethna_Backend   backendオブジェクト
      */
-    function getBackend()
+    public function getBackend()
     {
         return $this->class_factory->getObject('backend');
     }
@@ -919,7 +965,7 @@ class Ethna_Controller
      *  @param  mixed   $fallback_action_name   アクション名が決定できなかった場合に実行されるアクション名
      *  @return mixed   0:正常終了 Ethna_Error:エラー
      */
-    function _trigger_WWW($default_action_name = "", $fallback_action_name = "")
+    private function _trigger_WWW($default_action_name = "", $fallback_action_name = "")
     {
         // アクション名の取得
         $action_name = $this->_getActionName($default_action_name, $fallback_action_name);
@@ -1009,7 +1055,7 @@ class Ethna_Controller
      *  @param  mixed   $default_action_name    指定のアクション名
      *  @return mixed   0:正常終了 Ethna_Error:エラー
      */
-    function _trigger_CLI($default_action_name = "")
+    private function _trigger_CLI($default_action_name = "")
     {
         return $this->_trigger_WWW($default_action_name);
     }
@@ -1021,7 +1067,7 @@ class Ethna_Controller
      *  @param  mixed   $action_name    指定のアクション名
      *  @return mixed   0:正常終了 Ethna_Error:エラー
      */
-    function _trigger_XMLRPC($action_name = "")
+    private function _trigger_XMLRPC($action_name = "")
     {
         // prepare xmlrpc server
         $xmlrpc_gateway_method_name = "_Ethna_XmlrpcGateway";
@@ -1073,7 +1119,7 @@ class Ethna_Controller
      *
      *  @access public
      */
-    function trigger_XMLRPC($method, $param)
+    private function trigger_XMLRPC($method, $param)
     {
         // アクション定義の取得
         $action_obj = $this->_getAction($method);
index 14dd631..5307014 100644 (file)
@@ -127,7 +127,7 @@ class {$project_id}_Controller extends Ethna_Controller
     /**
      *  @var    array   class definition.
      */
-    protected $class = array(
+    public $class = array(
         /*
          *  TODO: When you override Configuration class, Logger class,
          *        SQL class, don't forget to change definition as follows!
index 7270124..e2fd8de 100644 (file)
@@ -11,7 +11,7 @@ class Dummy_Ethna_Error extends Ethna_Error
     //  nothing defined.
 }
 
-function dummy_error_callback_global(&$error)
+function dummy_error_callback_global($error)
 {
     $GLOBALS['_dummy_error_callback_global'] = $error->getMessage();
 }
index f623759..c6ad3d4 100644 (file)
@@ -13,7 +13,7 @@ class Ethna_Config_Test extends Ethna_UnitTestBase
     function setUp()
     {
         // etcディレクトリを上書き
-        $this->ctl->directory['etc'] = dirname(__FILE__);
+        $this->ctl->setDirectory('etc', dirname(__FILE__));
         $this->config = $this->ctl->getConfig();
         $this->filename = dirname(__FILE__) . '/ethna-ini.php';
     }
index ce28306..a0198b1 100644 (file)
@@ -25,8 +25,8 @@ class Ethna_Logger_Test extends Ethna_UnitTestBase
 
     function _resetLoggerSetting($config)
     {
-        unset($this->ctl->class_factory->object['logger']);
-        $config_obj = $this->ctl->class_factory->object['config'];
+        unset($this->ctl->getClassFactory()->object['logger']);
+        $config_obj = $this->ctl->getClassFactory()->object['config'];
         $config_obj->config = $config;
     }
 
index d557b79..c34a688 100644 (file)
@@ -32,7 +32,7 @@ class Ethna_Plugin_Csrf_Session_Test extends Ethna_UnitTestBase
         $plugin = $ctl->getPlugin();
         $this->csrf = $plugin->getPlugin('Csrf', 'Session');
         $this->assertTrue(is_object($this->csrf), 'getPlugin failed');
-        $this->csrf->session = new Ethna_Session_Dummy($ctl, $ctl->appid);
+        $this->csrf->session = new Ethna_Session_Dummy($ctl, $ctl->getAppId());
     }
 
     function testGetName()
index 9e18a0e..8171bc2 100644 (file)
@@ -18,7 +18,7 @@ class Ethna_Plugin_Validator_Strmaxcompat_Test extends Ethna_UnitTestBase
     {
         $ctl = new Ethna_Controller();
         $ctl->setClientEncoding('EUC-JP');
-        $ctl->action_form = new Ethna_ActionForm($ctl);
+        $ctl->setActionForm(new Ethna_ActionForm($ctl));
         $this->local_ctl = $ctl;
         $plugin = $ctl->getPlugin();
         $this->vld = $plugin->getPlugin('Validator', 'Strmaxcompat');
index 42bc1aa..59d2cde 100644 (file)
@@ -18,7 +18,7 @@ class Ethna_Plugin_Validator_Strmincompat_Test extends Ethna_UnitTestBase
     {
         $ctl = new Ethna_Controller();
         $ctl->setClientEncoding('EUC-JP');
-        $ctl->action_form = new Ethna_ActionForm($ctl);
+        $ctl->setActionForm(new Ethna_ActionForm($ctl));
         $this->local_ctl = $ctl;
         $plugin = $ctl->getPlugin();
         $this->vld = $plugin->getPlugin('Validator', 'Strmincompat');
index 95eab30..bf2bb43 100644 (file)
@@ -41,16 +41,16 @@ class Ethna_UnitTestBase extends UnitTestCase
         $this->backend = $this->ctl->getBackend();
 
         // actionform, actionerror.
-        if ($this->ctl->action_form === null) {
-            $this->ctl->action_form = new Ethna_ActionForm($this->ctl);
-            $this->backend->setActionForm($this->ctl->action_form);
+        if ($this->ctl->getActionForm() === null) {
+            $this->ctl->setActionForm(new Ethna_ActionForm($this->ctl));
+            $this->backend->setActionForm($this->ctl->getActionForm());
         }
-        $this->af = $this->ctl->action_form;
+        $this->af = $this->ctl->getActionForm();
         $this->ae = $this->ctl->getActionError();
 
         // viewclass
-        if ($this->ctl->view === null) {
-            $this->ctl->view = new Ethna_ViewClass($this->backend, '', '');
+        if ($this->ctl->getView() === null) {
+            $this->ctl->setView(new Ethna_ViewClass($this->backend, '', ''));
         }
     }
 }