public static function instance()
 {
     if (!isset(self::$_instance)) {
         self::$_instance = new PriceScraperController();
     }
     return self::$_instance;
 }
示例#2
0
 public function index()
 {
     require APP . 'views/_templates/header.php';
     require APP . 'views/home/index.php';
     require APP . 'views/_templates/footer.php';
     echo PriceScraperController::instance()->productDiscountJob();
     // PriceScraper::instance()->resealedPagesJob();
     // PriceScraper::instance()->closeDbConnection();
 }
示例#3
0
 /**
  * "Start" the application:
  * Analyze the URL elements and calls the according controller/method or the fallback
  */
 public function __construct()
 {
     // create array with URL parts in $url
     $this->getUrlWithoutModRewrite();
     // check for controller: no controller given ? then load start-page
     if (!$this->url_controller) {
         require APP . 'controllers/home.php';
         $page = new PriceScraperController();
         $page->index();
     } elseif (file_exists(APP . 'controllers/' . $this->url_controller . '.php')) {
         // here we did check for controller: does such a controller exist ?
         // if so, then load this file and create this controller
         // example: if controller would be "car", then this line would translate into: $this->car = new car();
         require APP . 'controllers/' . $this->url_controller . '.php';
         $this->url_controller = new $this->url_controller();
         // check for method: does such a method exist in the controller ?
         if (method_exists($this->url_controller, $this->url_action)) {
             if (!empty($this->url_params)) {
                 // Call the method and pass arguments to it
                 call_user_func_array(array($this->url_controller, $this->url_action), $this->url_params);
             } else {
                 // If no parameters are given, just call the method without parameters, like $this->home->method();
                 $this->url_controller->{$this->url_action}();
             }
         } else {
             if (strlen($this->url_action) == 0) {
                 // no action defined: call the default index() method of a selected controller
                 $this->url_controller->index();
             } else {
                 // defined action not existent: show the error page
                 require APP . 'controllers/error.php';
                 $page = new Error();
                 $page->index();
             }
         }
     } else {
         require APP . 'controllers/error.php';
         $page = new Error();
         $page->index();
     }
 }
<?php

include 'PriceScraper.php';
PriceScraperController::instance()->productDiscountJob();
// PriceScraper::instance()->resealedPagesJob();
// PriceScraper::instance()->closeDbConnection();