Example #1
0
 public function updatePaths()
 {
     $this->set('pff_path_public', $this->_publicFolder);
     $this->set('pff_path_css', $this->_cssFolder);
     $this->set('pff_path_img', $this->_imgFolder);
     $this->set('pff_path_js', $this->_jsFolder);
     if (ModuleManager::isLoaded('pff2-s3')) {
         $s3 = ModuleManager::loadModule('pff2-s3');
         $this->set('pff_path_files', $s3->getCloudfrontUrl() ?: $this->_filesFolder);
     } else {
         $this->set('pff_path_files', $this->_filesFolder);
     }
     $this->set('pff_path_vendor', $this->_vendorFolder);
     $this->set('pff_root_ext', $this->_app->getExternalPath());
 }
Example #2
0
 /**
  * Called before the controller is deleted.
  *
  * The view's render method is called for each view registered.
  *
  * @throws ViewException
  */
 public function __destruct()
 {
     $this->_output->outputHeader();
     if (!$this->_isRenderAction) {
         if (isset($this->_view)) {
             if (is_array($this->_view)) {
                 $this->_app->getHookManager()->runBeforeView(array('controller' => $this));
                 foreach ($this->_view as $view) {
                     $view->render();
                 }
                 $this->_app->getHookManager()->runAfterView();
             } elseif (is_a($this->_view, '\\pff\\AView')) {
                 $this->_app->getHookManager()->runBeforeView(array('controller' => $this));
                 $this->_view->render();
                 $this->_app->getHookManager()->runAfterView();
             } else {
                 throw new ViewException("The specified View is not valid.");
             }
         }
     } else {
         if (isset($this->_view)) {
             if (is_array($this->_view)) {
                 foreach ($this->_view as $view) {
                     $this->_app->getHookManager()->runBeforeView(array('controller' => $this));
                     $view->render();
                 }
             } elseif (is_a($this->_view, '\\pff\\AView')) {
                 $this->_app->getHookManager()->runBeforeView(array('controller' => $this));
                 $this->_view->render();
             } else {
                 throw new ViewException("The specified View is not valid.");
             }
         }
     }
 }
Example #3
0
 private static function loadTemplate($templateName, \pff\App $app, $templateType)
 {
     $mm = $app->getModuleManager();
     switch ($templateType) {
         case 'php':
             $templateName = self::checkMobile($templateName, $mm, 'php');
             return new LayoutPHP($templateName, $app);
             break;
         case 'tpl':
         case 'smarty':
             $templateName = self::checkMobile($templateName, $mm, 'smarty');
             return new LayoutSmarty($templateName, $app);
             break;
         default:
             $templateName = self::checkMobile($templateName, $mm, 'php');
             return new LayoutPHP($templateName, $app);
             break;
     }
 }
Example #4
0
 public function testRunFailsWithInvalidController()
 {
     $this->setExpectedException('\\pff\\Exception\\RoutingException');
     $this->object->run();
 }