project() public méthode

Get the project object (shorthand alias)
public project ( ) : Project
Résultat Pop\Project\Project
Exemple #1
0
 public function testRoute()
 {
     $r = new Router(array('/' => 'Pop\\Mvc\\Controller'));
     $r->route(new Project(new Config(array())));
     $this->assertInstanceOf('Pop\\Mvc\\Controller', $r->controller());
     $this->assertInstanceOf('Pop\\Project\\Project', $r->project());
 }
 /**
  * Event-based auth check
  *
  * @param  \Pop\Mvc\Router $router
  * @return mixed
  */
 public static function auth($router)
 {
     $sess = Session::getInstance();
     $site = Sites::getSite();
     $basePath = $site->base_path;
     $resource = $router->getControllerClass();
     $permission = $router->getAction();
     $isFrontController = substr_count($resource, '\\') == 2;
     // Check for the resource and permission
     if (!$isFrontController && $resource != 'Phire\\Controller\\Phire\\Install\\IndexController') {
         if (null === $router->project()->getService('acl')->getResource($resource)) {
             if ($resource != 'Phire\\Controller\\Phire\\IndexController') {
                 $router->project()->getService('acl')->addResource($resource);
             } else {
                 $resource = null;
                 $permission = null;
             }
         }
         if (null !== $permission && null !== $resource && !method_exists($resource, $permission)) {
             $permission = 'error';
         }
         if ($router->controller()->getRequest()->getPath(0) == 'index' || $router->controller()->getRequest()->getPath(0) == 'add') {
             $permId = $router->controller()->getRequest()->getPath(1);
             if (null !== $permId && is_numeric($permId)) {
                 $permission .= '_' . $permId;
             }
         }
         // Get the user URI
         $uri = APP_URI == '' || strtolower($router->project()->getService('acl')->getType()->type) == 'user' ? APP_URI : '/' . strtolower($router->project()->getService('acl')->getType()->type);
         // If reset password flag is set
         if (isset($sess->reset_pwd) && $_SERVER['REQUEST_URI'] != $basePath . $uri . '/profile' && $_SERVER['REQUEST_URI'] != $basePath . $uri . '/login' && $_SERVER['REQUEST_URI'] != $basePath . $uri . '/logout') {
             \Pop\Http\Response::redirect($basePath . $uri . '/profile');
             return \Pop\Event\Manager::KILL;
             // If not logged in for unsubscribe and required, redirect to the system login
         } else {
             if ($_SERVER['REQUEST_URI'] == $basePath . $uri . '/unsubscribe' && $router->project()->getService('acl')->getType()->unsubscribe_login && !$router->project()->getService('acl')->isAuth($resource, $permission)) {
                 \Pop\Http\Response::redirect($basePath . $uri . '/login');
                 return \Pop\Event\Manager::KILL;
                 // Else, if not logged in or allowed, redirect to the system login
             } else {
                 if ($_SERVER['REQUEST_URI'] != $basePath . $uri . '/login' && $_SERVER['REQUEST_URI'] != $basePath . $uri . '/register' && $_SERVER['REQUEST_URI'] != $basePath . $uri . '/forgot' && $_SERVER['REQUEST_URI'] != $basePath . $uri . '/unsubscribe' && substr($_SERVER['REQUEST_URI'], 0, strlen($basePath . $uri . '/json')) != $basePath . $uri . '/json' && strpos($_SERVER['REQUEST_URI'], $basePath . $uri . '/verify') === false && !$router->project()->getService('acl')->isAuth($resource, $permission)) {
                     \Pop\Http\Response::redirect($basePath . $uri . '/login');
                     return \Pop\Event\Manager::KILL;
                     // Else, if logged in and allowed, and a system access URI, redirect back to the system
                 } else {
                     if (($_SERVER['REQUEST_URI'] == $basePath . $uri . '/login' || $_SERVER['REQUEST_URI'] == $basePath . $uri . '/register' || $_SERVER['REQUEST_URI'] == $basePath . $uri . '/forgot') && $router->project()->getService('acl')->isAuth($resource, $permission)) {
                         \Pop\Http\Response::redirect($basePath . ($uri == '' ? '/' : $uri));
                         return \Pop\Event\Manager::KILL;
                     }
                 }
             }
         }
     }
 }