/** * * @return Yasc_App */ public function getApp() { if (null === $this->_app) { $this->_app = Yasc_App::getInstance(); } return $this->_app; }
/** * * @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); }
/** * * @param array $functions */ public function __construct(array $functions) { $this->_functions = $functions; $this->_request = Yasc_App::getInstance()->getRequest(); }
/** * * @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]; }
public function __construct() { $this->_app = Yasc_App::getInstance(); $this->_request = $this->_app->getRequest(); }
/** * * @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; }