Example #1
0
 /**
  * 
  * @param \Puzzlout\Framework\Core\Application $app
  * @param string $url
  * @throws \Exception
  */
 public function __construct(Application $app)
 {
     if (is_null($app)) {
         throw new \Exception('$app cannot be null!', 0, null);
     }
     parent::__construct($app);
     $request = new Request($app);
     $this->url = $request->RequestUriExist() ? $request->requestURI() : "";
 }
 /**
  * Set the view filename for the current request.
  * 
  * @throws \InvalidArgumentException thrown when the $action parameter is null or empty.
  */
 public function setView()
 {
     if (!is_string($this->action) || empty($this->action)) {
         $errMessage = 'The action value must be a string and not be empty';
         throw new \InvalidArgumentException($errMessage, GeneralErrors::VALUE_IS_NOT_OF_EXPECTED_TYPE);
     }
     if (\Puzzlout\Framework\Core\Request::Init($this->app)->IsPost()) {
         //No view needed for Ajax calls.
         return;
     }
     $this->view = \Puzzlout\Framework\Core\ViewLoader::Init($this)->GetView();
     $this->page->setContentFile($this->view);
 }