<?php // +----------------------------------------------------------------------+ // | Copyright 2005-2009 the Seasar Foundation and the Others. | // +----------------------------------------------------------------------+ // | Licensed under the Apache License, Version 2.0 (the "License"); | // | you may not use this file except in compliance with the License. | // | You may obtain a copy of the License at | // | | // | http://www.apache.org/licenses/LICENSE-2.0 | // | | // | Unless required by applicable law or agreed to in writing, software | // | distributed under the License is distributed on an "AS IS" BASIS, | // | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | // | either express or implied. See the License for the specific language | // | governing permissions and limitations under the License. | // +----------------------------------------------------------------------+ /** * S2Containerを使用ã™ã‚‹Zend_Controllerã®ã‚¢ã‚¯ã‚·ãƒ§ãƒ³ãƒ˜ãƒ«ãƒ‘ーã§ã™ã€‚ * * @copyright 2005-2009 the Seasar Foundation and the Others. * @license http://www.apache.org/licenses/LICENSE-2.0 * @link http://s2container.php5.seasar.org/ * @version SVN: $Id:$ * @since Class available since Release 2.0.1 * @package Seasar_Zf_Controller * @author klove */ class Seasar_Zf_Controller_S2ActionHelper extends Zend_Controller_Action_Helper_Abstract { /** * モジュールディレクトリã®diconsディレクトリ以下ã«ã‚ã‚‹S2Containerè¨å®šãƒ•ã‚¡ã‚¤ãƒ«ã‚’èªã¿è¾¼ã¿ã¾ã™ã€‚ * 次ã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªæ§‹æˆã‚’ã¨ã‚Šã¾ã™ã€‚ * - module directory/ * +- dicons/ * +- contorller name/ * +- action name.php * * S2Containerè¨å®šãƒ•ã‚¡ã‚¤ãƒ«å†…ã§ã¯ã€æ¬¡ã®å¤‰æ•°ãŒä½¿ç”¨å¯èƒ½ã§ã™ã€‚ * - @var Zend_Controller_Request_Abstract $request * - @var string $module モジュールå * - @var string $controller コントãƒãƒ¼ãƒ©å * - @var string $action アクションå * - @var string $moduleDir モジュールディレクトリパス * * @see Zend_Controller_Action_Helper_Abstract::preDispatch() */ public function preDispatch() { $request = $this->getRequest(); $module = $request->getModuleName(); $controller = $request->getControllerName(); $action = $request->getActionName(); $dirs = $this->getFrontController()->getControllerDirectory(); if (empty($module) || !isset($dirs[$module])) { $module = $this->getFrontController()->getDispatcher()->getDefaultModule(); } $moduleDir = dirname($dirs[$module]); $dicons = array("$moduleDir/dicons/dicon.php", "$moduleDir/dicons/$controller.php", "$moduleDir/dicons/$controller/dicon.php", "$moduleDir/dicons/$controller/$action.php"); foreach($dicons as $dicon) { if (file_exists($dicon)) { require_once(APPLICATION_PATH . '/configs/s2.php'); require($dicon); } } } /** * @see Zend_Controller_Action_Helper_Abstract::getName() */ public function getName() { return 'S2'; } /** * @see Zend_Controller_Action_Helper_Abstract::direct() * @param string $key コンãƒãƒ¼ãƒãƒ³ãƒˆã‚ー * @return object */ public function direct($key) { require_once(APPLICATION_PATH . '/configs/s2.php'); return \seasar\container\S2ApplicationContext::create()->getComponent($key); } /** * @param string $key コンãƒãƒ¼ãƒãƒ³ãƒˆã‚ー * @return object */ public function __get($key) { return $this->direct($key); } }