私は現在ZendFrameworkを学んでいて、次の構文に出くわしました。
class Zend_Controller_Action_Helper_Redirector extends Zend_Controller_Action_Helper_Abstract
{
/**
* Perform a redirect to an action/controller/module with params
*
* @param string $action
* @param string $controller
* @param string $module
* @param array $params
* @return void
*/
public function gotoSimple($action, $controller = null, $module = null, array $params = array())
{
$this->setGotoSimple($action, $controller, $module, $params);
if ($this->getExit()) {
$this->redirectAndExit();
}
}
/**
* direct(): Perform helper when called as
* $this->_helper->redirector($action, $controller, $module, $params)
*
* @param string $action
* @param string $controller
* @param string $module
* @param array $params
* @return void
*/
public function direct($action, $controller = null, $module = null, array $params = array())
{
$this->gotoSimple($action, $controller, $module, $params);
}
}
Zend Frameworkでは、このクラスのdirect()メソッドは、次の構文を使用して呼び出すことができます。
$this->_helper->redirector('index','index');
ここで、redirectorは、メソッドを呼び出すコントローラーオブジェクト内にある_helperオブジェクト内のオブジェクト(!)です。ここでの構文上の糖衣は、メソッドではなくオブジェクトにパラメーターを渡すことができるということです。これは次のように記述します。
$this->_helper->redirector->gotoSimple('index','index');
..これはもちろんすべて元気でダンディです。
これが私の質問です:このdirect()メソッドはOO PHPの標準ですか?または、この機能はZend Frameworkに組み込まれていますか?これに関するドキュメントが見つかりません。
ありがとう!