当前位置: 首页>>代码示例>>PHP>>正文


PHP ControllerFactory::create方法代码示例

本文整理汇总了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;
 }
开发者ID:eshopino,项目名称:api-helper,代码行数:17,代码来源:Application.php

示例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;
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:18,代码来源:ControllerCall.class.php

示例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();
     }
 }
开发者ID:anzasolutions,项目名称:simlandia,代码行数:40,代码来源:router.class.php

示例4: getController

 public static function getController($name, $action = null, $params = null)
 {
     $mycontroller = ControllerFactory::create($name, $action, $params);
     return $mycontroller;
 }
开发者ID:Fulbert28,项目名称:PedaFramework,代码行数:5,代码来源:Application.class.php

示例5: comment

 /**
  * @Invocable
  */
 protected function comment()
 {
     ControllerFactory::create('Comment')->add($this, 'show');
 }
开发者ID:anzasolutions,项目名称:simlandia,代码行数:7,代码来源:videocontroller.class.php

示例6: loader

 /**
  * Load and execute controller directly.
  *
  * @author anza
  */
 public function loader()
 {
     $controller = ControllerFactory::create($this->registry);
     $controller->execute();
 }
开发者ID:anzasolutions,项目名称:simland,代码行数:10,代码来源:Router.class.php


注:本文中的ControllerFactory::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。