run() публичный Метод

Run the project.
public run ( ) : void
Результат void
Пример #1
0
 public function testConstructor()
 {
     $p = new Project(new Config(array('databases' => array('testdb' => Db::factory('Sqlite', array('database' => __DIR__ . '/../tmp/test.sqlite'))), 'defaultDb' => 'testdb')), array('Test' => new Config(array('some' => 'thing'))), new Router(array('Pop\\Mvc\\Controller' => new Controller())));
     $p->run();
     $this->assertInstanceOf('Pop\\Project\\Project', $p);
 }
Пример #2
0
 /**
  * Add any project specific code to this method for run-time use here.
  *
  * @return void
  */
 public function run()
 {
     // Set the services
     $this->setService('acl', 'Phire\\Auth\\Acl');
     $this->setService('auth', 'Phire\\Auth\\Auth');
     $this->setService('phireNav', 'Pop\\Nav\\Nav');
     // Get loaded modules and add their routes and nav
     $modules = $this->modules();
     $nav = $this->getService('phireNav');
     // Load module routes and nav
     foreach ($modules as $name => $config) {
         $cfg = $config->asArray();
         // Add nav
         if (isset($cfg['nav'])) {
             $nav->addBranch($cfg['nav'], true);
         }
         // Add routes
         if (isset($cfg['routes'])) {
             $routes = APP_URI == '' && isset($cfg['routes'][APP_URI]) ? $cfg['routes'][APP_URI] : $cfg['routes'];
             $this->router->addControllers($routes);
         }
     }
     // If the path is the install path
     if (substr($_SERVER['REQUEST_URI'], 0, strlen(BASE_PATH . APP_URI . '/install')) == BASE_PATH . APP_URI . '/install') {
         parent::run();
         // Else, load any user routes and initialize the ACL object
     } else {
         $this->loadUserRoutes();
         $this->initAcl();
         // Set the auth method to trigger on 'dispatch.pre'
         $this->attachEvent('dispatch.pre', 'Phire\\Project::auth');
         // Set up routing error check on 'route.error'
         $this->attachEvent('route.error', 'Phire\\Project::error');
         // If SSL is required for this user type, and not SSL,
         // redirect to SSL, else, just run
         if ($this->getService('acl')->getType()->force_ssl && !($_SERVER['SERVER_PORT'] == '443')) {
             \Pop\Http\Response::redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
         } else {
             parent::run();
         }
     }
 }
Пример #3
0
        $this->view = View::factory($this->viewPath . '/index.phtml', array('title' => 'Test Event', 'subtitle' => 'Home Page', 'content' => 'This is the home page'));
        $this->send();
    }
    public function users()
    {
        $this->view = View::factory($this->viewPath . '/index.phtml', array('title' => 'Test Event', 'subtitle' => 'Users Page', 'content' => 'This is the users page'));
        $this->send();
    }
    public function error()
    {
        $this->view = View::factory($this->viewPath . '/index.phtml', array('title' => 'Test Event', 'subtitle' => 'Error Page', 'content' => 'Page not found.'));
        $this->send(404);
    }
}
try {
    $project = new Project(null, null, new Router(array('/' => 'IndexController')));
    $project->attachEvent('dispatch', function ($controller) {
        if ($controller->getRequest()->getRequestUri() == '/') {
            $controller->getView()->set('subtitle', 'This is the REVISED Home Page Subtitle.');
            return 'Hello World! This is the home page!';
        }
    });
    $project->attachEvent('dispatch', function ($controller, $result) {
        if ($controller->getRequest()->getRequestUri() == '/') {
            $controller->getView()->set('content', $result);
        }
    });
    $project->run();
} catch (\Exception $e) {
    echo $e->getMessage();
}