本文整理汇总了PHP中Yaf_Application::isModuleName方法的典型用法代码示例。如果您正苦于以下问题:PHP Yaf_Application::isModuleName方法的具体用法?PHP Yaf_Application::isModuleName怎么用?PHP Yaf_Application::isModuleName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Yaf_Application
的用法示例。
在下文中一共展示了Yaf_Application::isModuleName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setDefaultModule
/**
* Set the default module name
*
* @param string $module
* @return Yaf_Dispatcher
*/
public function setDefaultModule($module)
{
if (Yaf_Application::isModuleName($module) || strtolower($module) == 'index') {
$this->_default_module = ucfirst((string) $module);
}
return $this;
}
示例2: route
/**
* Processes a request and sets its controller and action based on a
* supervar value.
*
* @param Yaf_Request_Abstract
*
* @return Yaf_Request_Abstract|boolean
*/
public function route(Yaf_Request_Abstract $request)
{
$requestUri = $request->getQuery($this->_varName);
if ($requestUri == null || $requestUri == '') {
return false;
}
$module = null;
$controller = null;
$action = null;
$rest = null;
$path = trim($requestUri, Yaf_Router::URI_DELIMITER);
if ($path != '' && $path != '/') {
$path = explode(Yaf_Router::URI_DELIMITER, $path);
if (Yaf_Application::isModuleName($path[0])) {
$module = $path[0];
array_shift($path);
}
if (count($path) && !empty($path[0])) {
$controller = $path[0];
array_shift($path);
}
if (count($path) && !empty($path[0])) {
$action = $path[0];
array_shift($path);
}
$rest = implode(Yaf_Router::URI_DELIMITER, $path);
$actionPrefer = Yaf_G::iniGet('yaf.action_prefer');
if ($module == null && $controller == null && $action == null) {
if ($actionPrefer == true) {
$action = $rest;
} else {
$controller = $rest;
}
$rest = null;
} elseif ($module == null && $action == null && $rest == null) {
if ($actionPrefer == true) {
$action = $controller;
$controller = null;
}
} elseif ($controller == null && $action == null && $rest != null) {
$controller = $module;
$action = $rest;
$module = null;
$rest = null;
} elseif ($action == null && $rest == null) {
$action = $controller;
$controller = $module;
$module = null;
} elseif ($controller == null && $action == null) {
$controller = $module;
$action = $rest;
$module = null;
$rest = null;
} elseif ($action == null) {
$action = $rest;
$rest = null;
}
if ($module != null) {
$request->setModuleName($module);
}
if ($controller != null) {
$request->setControllerName($controller);
}
if ($action != null) {
$request->setActionName($action);
}
$params = array();
if ($rest != null && trim($rest) != '') {
$path = explode(Yaf_Router::URI_DELIMITER, $rest);
if (($numSegs = count($path)) != 0) {
for ($i = 0; $i < $numSegs; $i = $i + 2) {
$key = urldecode($path[$i]);
$val = isset($path[$i + 1]) ? urldecode($path[$i + 1]) : null;
$params[$key] = isset($params[$key]) ? array_merge((array) $params[$key], array($val)) : $val;
}
}
$request->setParam($params);
}
}
return true;
}
示例3: handle
private function handle(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response, Yaf_View_Interface $view)
{
$request->setDispatched(true);
$app = $this->getApplication();
$appDir = $app->getAppDirectory();
if ($appDir == '') {
throw new Yaf_Exception_StartupError('Yaf_Dispatcher requires ' . 'Yaf_Application(which set the application.directory) ' . 'to be initialized first.');
}
$module = $request->getModuleName();
if (empty($module)) {
throw new Yaf_Exception_DispatchFailed('Unexcepted an empty module name');
}
if (!Yaf_Application::isModuleName($module)) {
throw new Yaf_Exception_LoadFailed_Module('There is no module ' . $module);
}
$controllerName = $request->getControllerName();
if (empty($controllerName)) {
throw new Yaf_Exception_DispatchFailed('Unexcepted an empty controller name');
}
$className = $this->getController($appDir, $module, $controllerName);
if (!$className) {
return false;
}
$controller = new $className($request, $response, $view);
if (!$controller instanceof Yaf_Controller_Abstract) {
throw new Yaf_Exception_TypeError('Controller must be an instance of Yaf_Controller_Abstract');
}
$viewDir = $view->getScriptPath();
//template dir might be set from the __construct
if (empty($viewDir)) {
$templateDir = '';
if ($this->_default_module == $module) {
$templateDir = $appDir . DIRECTORY_SEPARATOR . Yaf_Loader::YAF_VIEW_DIRECTORY_NAME;
} else {
$templateDir = $appDir . DIRECTORY_SEPARATOR . Yaf_Loader::YAF_MODULE_DIRECTORY_NAME . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . Yaf_Loader::YAF_VIEW_DIRECTORY_NAME;
}
$view->setScriptPath($templateDir);
unset($templateDir);
}
$action = $request->getActionName();
$actionMethod = $action . 'Action';
if (method_exists($controller, $actionMethod)) {
//Get all action method parameters
$methodParams = $this->getActionParams($className, $actionMethod);
if (null == $methodParams) {
$ret = call_user_func(array($controller, $actionMethod));
} else {
$ret = call_user_func_array(array($controller, $actionMethod), $this->prepareActionParams($request, $methodParams));
}
if (is_bool($ret) && $ret == false) {
return true;
}
} elseif (($actionController = $this->getAction($appDir, $controller, $action, $module)) != null) {
//check if not in actions vars we have the action
$actionMethod = 'execute';
if (method_exists($actionController, $actionMethod)) {
//Get all action method parameters
$methodParams = $this->getActionParams(get_class($actionController), $actionMethod);
$ret = null;
if (null == $methodParams) {
$ret = call_user_func(array($actionController, $actionMethod));
} else {
$ret = call_user_func_array(array($actionController, $actionMethod), $this->prepareActionParams($request, $methodParams));
}
if (is_bool($ret) && $ret == false) {
return true;
}
} else {
throw new Yaf_Exception_LoadFailed_Action('There is no method ' . $actionMethod . ' in ' . get_class($controller) . '::$actions');
}
} else {
return false;
}
if ($this->_auto_render == true) {
if ($this->_instantly_flush == true) {
$controller->display($action);
} else {
$ret = $controller->render($action);
$response->setBody($ret);
}
}
$controller = null;
}