Exemplo n.º 1
0
 /**
  *
  * @return Yasc_App
  */
 public function getApp()
 {
     if (null === $this->_app) {
         $this->_app = Yasc_App::getInstance();
     }
     return $this->_app;
 }
Exemplo n.º 2
0
Arquivo: Url.php Projeto: nebiros/yasc
 /**
  *
  * @param string $path
  * @return string
  */
 protected function urlFor($path)
 {
     $appConfig = \Yasc_App::config()->getOption("appConfig");
     $options = array();
     if (isset($appConfig["url_force_https"])) {
         $options["url_force_https"] = (bool) $appConfig["url_force_https"];
     }
     return Yasc_App::getInstance()->getRouter()->urlFor($path, $options);
 }
Exemplo n.º 3
0
 /**
  *
  * @param array $functions
  */
 public function __construct(array $functions)
 {
     $this->_functions = $functions;
     $this->_request = Yasc_App::getInstance()->getRequest();
 }
Exemplo n.º 4
0
 /**
  *
  * @param string $name
  * @param int $type
  * @return mixed 
  */
 public function getHelper($name, $type = null)
 {
     $helperId = null;
     switch ((int) $type) {
         case self::HELPER_TYPE_FUNCTION:
             $paths = $this->getFunctionHelperPaths();
             $helperId = $name . "-" . self::HELPER_TYPE_FUNCTION;
             break;
         case self::HELPER_TYPE_VIEW:
         default:
             $paths = $this->getViewHelperPaths();
             $helperId = $name . "-" . self::HELPER_TYPE_VIEW;
             break;
     }
     $className = trim(ucfirst((string) $name));
     foreach ($paths as $classPrefix => $path) {
         $class = $classPrefix . $className;
         if (true === class_exists($class) && false === isset($this->_helpers[$helperId])) {
             if (true === is_callable(array($class, "getInstance"))) {
                 $this->_helpers[$helperId] = call_user_func(array($class, "getInstance"));
             } else {
                 $this->_helpers[$helperId] = new $class();
             }
             if (true === is_callable(array($this->_helpers[$helperId], "setView"))) {
                 $this->_helpers[$helperId]->setView(Yasc_App::getInstance()->getView());
             }
             break;
         }
     }
     if (null === $this->_helpers[$helperId]) {
         throw new Yasc_App_Exception("Helper '{$name}' was not found in '" . implode("', '", $paths) . "'");
     }
     return $this->_helpers[$helperId];
 }
Exemplo n.º 5
0
 public function __construct()
 {
     $this->_app = Yasc_App::getInstance();
     $this->_request = $this->_app->getRequest();
 }
Exemplo n.º 6
0
 /**
  *
  * @param string $filename
  * @return Yasc_View
  */
 public function setViewScript($filename)
 {
     $this->_viewScript = null;
     $folders = Yasc_App::getInstance()->getConfig()->getViewsPaths();
     foreach ($folders as $path) {
         if (true === is_file(realpath($path . "/" . $filename . ".phtml"))) {
             $this->_viewScript = realpath($path . "/" . $filename . ".phtml");
             break;
         }
     }
     if (null === $this->_viewScript) {
         throw new Yasc_View_Exception("View file '{$filename}' not found in this paths: " . implode(", ", $folders));
     }
     return $this;
 }