Ejemplo n.º 1
0
 private static function writeMessageToFile($message)
 {
     $loggerPath = Configuration::read(ConfigurationParameters::APPLICATION_LOGGER_DIRECTORY);
     $resource = fopen($loggerPath, self::getFileMode($loggerPath));
     fwrite($resource, $message);
     fclose($resource);
 }
 protected function initialize()
 {
     $configuration = Configuration::read(ConfigurationParameters::DATABASE_CONNECTION);
     if (!is_null($configuration) && $configuration instanceof DatabaseConfiguration) {
         $this->setDataSource(DriverFactory::getDriver($configuration));
     } else {
         throw new DatabaseException(MessageCode::DATABASE_CONNECTION_CONFIGURATION_NOT_FOUND);
     }
 }
Ejemplo n.º 3
0
 public function exists($view)
 {
     $viewDirectory = Configuration::read(ConfigurationParameters::APPLICATION_VIEW_DIRECTORY);
     $viewTemplateFile = $viewDirectory . DIRECTORY_SEPARATOR . $view . Template::PHP_EXTENSION;
     if (!(is_dir($viewDirectory) && is_readable($viewDirectory) && is_file($viewTemplateFile))) {
         throw new WebException(MessageCode::WEB_VIEW_DIRECTORY_NOT_FOUND);
     }
     return $viewTemplateFile;
 }
Ejemplo n.º 4
0
 public function __construct($messageCode, $errorCode = 0, Exception $previous = null)
 {
     $messageBundle = Configuration::read(ConfigurationParameters::APPLICATION_MESSAGE_BUNDLE);
     if ($messageBundle instanceof MessageBundle) {
         parent::__construct($messageBundle->getMessage($messageCode), $errorCode, $previous);
     } elseif (is_array($messageBundle) && array_key_exists($messageCode, $messageBundle)) {
         parent::__construct($messageBundle[$messageCode], $errorCode, $previous);
     } else {
         parent::__construct($messageCode, $errorCode, $previous);
     }
 }
Ejemplo n.º 5
0
 public function __construct()
 {
     $roles = Configuration::read(ConfigurationParameters::ACCESS_CONTROL_LIST_ROLES);
     if (!is_null($roles)) {
         foreach ($roles as $role) {
             $this->addRole($role);
         }
     }
     $rules = Configuration::read(ConfigurationParameters::ACCESS_CONTROL_LIST_RULES);
     if (!is_null($rules)) {
         foreach ($rules as $resource => $roles) {
             $this->addRule($resource, $roles);
         }
     }
 }
Ejemplo n.º 6
0
 public static function getFilePath($classname)
 {
     try {
         $sourceDirectories = Configuration::read(ConfigurationParameters::APPLICATION_SOURCE_DIRECTORY);
         if (!is_array($sourceDirectories)) {
             return null;
         }
         foreach ($sourceDirectories as $directory) {
             $recursiveIterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory));
             $regex = '/' . $classname . '\\.php$/';
             $regexIterator = new RegexIterator($recursiveIterator, $regex);
             $regexIterator->next();
             if ($regexIterator->valid()) {
                 return $regexIterator->current()->getRealPath();
             }
         }
         throw new Exception("Not Found.");
     } catch (Exception $e) {
         throw new WaspException(MessageCode::CLASS_FILE_NOT_FOUND, $e->getCode(), $e->getPrevious());
     }
 }
 public function load(RequestInterface $request)
 {
     $xmlFilePath = str_replace(Template::PHP_EXTENSION, Template::XML_EXTENSION, $this->getTemplate());
     if (file_exists($this->getTemplate()) != false && file_exists($xmlFilePath) != false) {
         $xmlTemplateTranslator = new XmlTemplateTranslator($this->getTemplate(), $xmlFilePath);
         $compiledXmlDirectory = Configuration::read(ConfigurationParameters::APPLICATION_XML_VIEW_DIRECTORY);
         $compiledXmlFile = $compiledXmlDirectory . md5($this->getTemplate() . time()) . Template::PHP_EXTENSION;
         $handle = fopen($compiledXmlFile, "w");
         fwrite($handle, $xmlTemplateTranslator->translate());
         fclose($handle);
         $view = ViewModel::getInstance($request);
         if (is_array($this->getParameters()) == true) {
             $view->import($this->getParameters());
         }
         ob_start();
         include_once $compiledXmlFile;
         $pageContent = ob_get_contents();
         ob_end_clean();
         unlink($compiledXmlFile);
         return $pageContent;
     } else {
         throw new WebException(MessageCode::WEB_VIEW_DIRECTORY_NOT_FOUND);
     }
 }