Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class App
- {
- private $fileOrderManager;
- private $pageManager;
- private $routes = [
- '/' => 'getIndex',
- '/admin' => 'getAdminPage',
- '/order' => 'save'
- ];
- function __construct($fileOrderManager,$pageManager)
- {
- $this->fileOrderManager=$fileOrderManager;
- $this->pageManager= $pageManager;
- }
- public function run()
- {echo "in run()<br>";
- $path = parse_url($_SERVER['REQUEST_URI']);
- echo 'path->'.$path."<br>";
- $method = $this->routes[$path['path']] ?? 'getIndex';
- echo "method->".$method.'<br>';
- if(!method_exists($this, $method)) {
- echo "return from run()<hr>";
- return; // throw exception
- }
- $this->$method();
- $this->pageManager->getIndex();
- $this->pageManager->getAdminPage();
- $this->fileOrderManager->save();
- //$this->fileOrderManager->list();
- }
- }
Add Comment
Please, Sign In to add comment