コード例 #1
0
ファイル: ApiMain.php プロジェクト: Tjorriemorrie/app
 /**
  * Gets controller from request, and delegates to given controller - checking of access permissions
  *
  * @return bool
  * @throws WikiaException
  * @throws ControllerNotFoundException
  */
 protected function accessAllowedByController()
 {
     // Code for instantination of controller copied from method WikiaDispatcher::dispatch
     $originalRequest = RequestContext::getMain()->getRequest();
     $app = WikiaApp::app();
     global $wgAutoloadClasses;
     // Determine the "base" name for the controller, stripping off Controller/Service/Module
     $controllerName = $app->getBaseName($originalRequest->getVal('controller'));
     if (empty($controllerName)) {
         return false;
     }
     // Service classes must be dispatched by full name otherwise we look for a controller.
     if ($app->isService($originalRequest->getVal('controller'))) {
         $controllerClassName = $app->getServiceClassName($controllerName);
     } else {
         $controllerClassName = $app->getControllerClassName($controllerName);
     }
     if (empty($wgAutoloadClasses[$controllerClassName])) {
         return false;
     }
     // Determine the final name for the controller and method based on any routing rules
     $controller = new $controllerClassName();
     /* @var $controller WikiaController */
     $accessAllowedByController = $controller->isAnonAccessAllowedInCurrentContext();
     return $accessAllowedByController;
 }