Ejemplo n.º 1
0
 /**
  * Get the instance of class "FileWriter" of the file
  * 
  * @param boolean $append
  * @return FileWriter
  */
 public function getWriter($append = false)
 {
     if (!Loader::classExists('FileWriter')) {
         Loader::load('FileWriter', 'utility');
     }
     $writer = new FileWriter($this->_path);
     return $writer;
 }
Ejemplo n.º 2
0
 /**
  * Create and return form layout element
  * 
  * @param string $layoutTagName
  * @return FormLayoutAbstract
  * @throws FileNotExistException
  */
 public function createLayout($layoutTagName)
 {
     $layoutClassName = NameManager::toClass('form_layout_' . trim(strtolower($layoutTagName)));
     if (!Loader::classExists($layoutClassName)) {
         $result = Loader::load($layoutClassName, 'html', true, false);
         if ($result == false) {
             $result = Loader::loadLibrary($layoutClassName);
             if ($result == false) {
                 $fileName = NameManager::toPhpFile($layoutClassName);
                 require_once 'exception/file_not_exist_exception.php';
                 throw new FileNotExistException($fileName);
             }
         }
     }
     $layoutInstance = new $layoutClassName($this);
     return $layoutInstance;
 }
Ejemplo n.º 3
0
 /**
  * Create connection instance that extends PDO
  * 
  * @return DbAdapterAbstract
  * @throws Exception
  */
 protected static function _connect()
 {
     $snake = 'db_adapter_' . strtolower(self::$_config['type']);
     $adapterName = NameManager::toClass($snake);
     Loader::load($adapterName, 'db');
     if (!Loader::classExists($adapterName)) {
         throw new ClassUndefinedException($adapterName);
     }
     $instance = new $adapterName(self::$_config);
     return $instance;
 }
Ejemplo n.º 4
0
 /**
  * Search error handler class and return its instance
  * 
  * @param string $subdir
  * @return ErrorHandlerStandard
  */
 protected function _searchErrorHandler($subdir)
 {
     $controllerDir = PathManager::getControllerDirectory();
     $dirs = array();
     if ($subdir != '') {
         $dirs = explode('/', trim($subdir, '/'));
     }
     $handler = null;
     $path = '';
     while (true) {
         $path = $controllerDir;
         if (count($dirs) > 0) {
             $path .= '/' . implode('/', $dirs);
         }
         if (file_exists($path . '/error_handler.php')) {
             require_once $path . '/error_handler.php';
             $className = NameManager::toClass(implode('_', $dirs) . '_error_handler');
             if (Loader::classExists($className)) {
                 $handler = new $className();
                 break;
             } else {
                 if (Loader::classExists('ErrorHandler')) {
                     $handler = new ErrorHandler();
                     break;
                 }
             }
         }
         if ($path == $controllerDir) {
             break;
         }
         array_pop($dirs);
     }
     if (!$handler instanceof ErrorHandlerStandard) {
         $handler = new ErrorHandlerStandard();
     }
     return $handler;
 }
Ejemplo n.º 5
0
 /**
  * Set the exception instance
  *
  * @param Exception $exception
  * @return void
  */
 public function setException($exception)
 {
     $this->exception = $exception;
     if (Loader::classExists('Logger') && self::$_logKey) {
         Logger::except($exception, self::$_logKey);
     }
 }