本文整理汇总了PHP中AbstractController::createAndRunAction方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractController::createAndRunAction方法的具体用法?PHP AbstractController::createAndRunAction怎么用?PHP AbstractController::createAndRunAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AbstractController
的用法示例。
在下文中一共展示了AbstractController::createAndRunAction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleRequest
/**
* Factory to get a view by module name. If the desired view is not available then an alternative view might get
* returned.
*
* @internal
*
* @throws \Exception
*
* @param string $module module name
* @param string $action
*
* @return view\AbstractView
*/
private function handleRequest($module, $action)
{
// there will always be something to view (otherwise we should get a nice error message)
$viewName = $this->getClassByModule($module);
/** @var \FeM\sPof\view\AbstractView $view */
$view = null;
try {
// for an action, there is a controller to handle it
if ($action) {
AbstractController::createAndRunAction($module, $action);
}
if (!class_exists($viewName)) {
// if file exists -> the class name does not match the filename
if (file_exists('view/' . $module . 'View.php')) {
throw new \FeM\sPof\exception\ClassNotFoundException(__('"%sView" requested, but missing definition in file "view/%sView.php", maybe a typo in the ' . 'class name?', $module, $module));
}
// file doesn't exist -> file probably need to get renamed
if (!file_exists('view/' . $module . 'View.php')) {
throw new \FeM\sPof\exception\ClassNotFoundException(__('"%sView" requested, but could not find the associated file "view/%sView.php"', $module, $module));
}
}
// class does exist, so get us a instance of it
$view = new $viewName();
$view->executeShow();
} catch (\Exception $e) {
Logger::getInstance()->warning(__("Could not instanciate class of type '%s'. Trying to find alternatives", $viewName));
// try to call the static implementation, we need this workaround, because this method is called staticly,
// directly on this class, so no late state binding, try to workaround by directly calling it and otherwise
// use local fallback
if (method_exists($viewName, 'handleException')) {
$viewName::handleException($e);
} else {
$viewName = $this->getClassByModule($this->defaultModule);
if (method_exists($viewName, 'handleException')) {
$viewName::handleException($e);
}
}
}
// we got a view we can proceed
if ($view instanceof view\AbstractView) {
return $view;
}
// try to call the static implementation, we need this workaround, because this method is called staticly,
// directly on this class, so no late state binding, try to workaround by directly calling it and otherwise
// use local fallback
if (method_exists($viewName, 'handleNoViewFound')) {
return $viewName::handleNoViewFound();
} else {
$viewName = $this->getClassByModule($this->defaultModule);
if (method_exists($viewName, 'handleNoViewFound')) {
return $viewName::handleNoViewFound();
}
}
if (empty($module)) {
self::death(_("\nNo module given, abort."));
} else {
self::death(__("\nCould not find a suitable view component for module '%s'.", $module));
}
}