本文整理汇总了PHP中ControllerFactory::create方法的典型用法代码示例。如果您正苦于以下问题:PHP ControllerFactory::create方法的具体用法?PHP ControllerFactory::create怎么用?PHP ControllerFactory::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ControllerFactory
的用法示例。
在下文中一共展示了ControllerFactory::create方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
try {
$request = $this->requestFactory->createRequest();
$controller = $this->controllerFactory->create($request);
$response = $controller->run($request);
} catch (AuthorizationException $e) {
$response = new Response(['message' => $e->getMessage()], 401);
} catch (ApiException $e) {
$response = new Response(['message' => $e->getMessage()], $e->getCode() ?: 400);
}
http_response_code($response->getCode());
header('Content-Type: application/json');
$body = json_encode($response->getData());
header('X-Api-Signature: ' . hash_hmac('sha256', $body, $this->configuration->getPrivateKey()));
echo $body;
}
示例2: __construct
function __construct($controller_name, $action, $format, $params)
{
//vecchio setup, e' stata aggiunta la creazione del controller
$this->controller = ControllerFactory::create($controller_name);
//hack per supportare i vecchi mapping con "php".
//$format = DataFormatManager::getFormatString($format);
$this->__check_reserved_action($action);
if ($format !== "raw") {
$this->__check_protected_action($action, $format);
}
DataFormatManager::checkFormatSupported($format);
$this->action = $action;
$this->format = $format;
$this->params = $params;
$this->format_helper = DataFormatManager::getFormat($format);
$this->execute_action = true;
$this->action_result = null;
}
示例3: validate
private static function validate($name)
{
try {
$url = URL::getInstance();
if ($name == null) {
if (Session::getInstance()->isStarted()) {
$url->setController(DEFAULT_SESSION_CONTROLLER);
$url->setAction(DEFAULT_SESSION_ACTION);
return DEFAULT_SESSION_CONTROLLER;
} else {
$url->setController(DEFAULT_REQUEST_CONTROLLER);
$url->setAction(DEFAULT_REQUEST_ACTION);
return DEFAULT_REQUEST_CONTROLLER;
}
}
$controller = $name . CONTROLLER;
$class = new ReflectionClass($controller);
if ($class->isAbstract()) {
throw new LogicException();
}
$classScope = $class->getConstant('SCOPE');
if ($class->implementsInterface('Context')) {
if (Scope::isAcceptable($classScope)) {
return $name;
}
if ($classScope == Scope::SESSION) {
$url->setController(DEFAULT_REQUEST_CONTROLLER);
$url->setAction(DEFAULT_REQUEST_ACTION);
return DEFAULT_REQUEST_CONTROLLER;
}
if ($classScope == Scope::REQUEST) {
ControllerFactory::create(DEFAULT_APPLICATION_CONTROLLER)->redirectToError();
}
}
return DEFAULT_APPLICATION_CONTROLLER;
} catch (LogicException $e) {
$e->getTraceAsString();
ControllerFactory::create(DEFAULT_APPLICATION_CONTROLLER)->redirectToError();
}
}
示例4: getController
public static function getController($name, $action = null, $params = null)
{
$mycontroller = ControllerFactory::create($name, $action, $params);
return $mycontroller;
}
示例5: comment
/**
* @Invocable
*/
protected function comment()
{
ControllerFactory::create('Comment')->add($this, 'show');
}
示例6: loader
/**
* Load and execute controller directly.
*
* @author anza
*/
public function loader()
{
$controller = ControllerFactory::create($this->registry);
$controller->execute();
}