private function parseFormat($format)
 {
     $this->format = $format;
     Strings::setIfEmpty($this->format, self::DEFAULT_FORMAT);
     preg_match('/\\{date(\\((.*)\\))?\\}/', $this->format, $dateMatches);
     $this->datePlace = $dateMatches[0];
     if (isset($dateMatches[2])) {
         $this->dateFormat = $dateMatches[2];
     }
 }
 /**
  *
  * @param string $query query part of library URL
  * @return string out namespace
  */
 private function outNamespace($query)
 {
     $queryParams = [$query];
     if (Strings::contains($query, '&')) {
         $queryParams = explode('&', $query);
     }
     foreach ($queryParams as $param) {
         list($arg, $value) = explode('=', $attribute);
         if ($arg == self::OUT_NAMESPACE_ARGUMENT) {
             return $value;
         }
     }
 }
 /**
  * @param string $alias resource alias
  */
 public function moduleNameAndPath($alias)
 {
     $isModuleResource = Strings::contains($alias, self::MODULE_SEPARATOR) && Strings::contains($alias, self::PATH_SEPARATOR) && strpos($alias, '.') < strpos($alias, '/');
     $module = APP_MODULE_NAME;
     $path = $alias;
     if ($isModuleResource) {
         list($module, $path) = explode(self::MODULE_SEPARATOR, $alias, 2);
         $path = trim($path, '/');
     }
     if (!Modules::instance()->exists($module)) {
         throw new ModuleNotFoundException($module);
     }
     return [$module, $path];
 }
 protected function checkConstraints($target)
 {
     if (Strings::isEmpty($this->value)) {
         throw new AnnotationException("Observer value cannot be empty.\n{$target->__toString()}");
     }
 }
require_once BASE_PATH . '/zool/util/log/LogProvider.php';
function displayException($exception)
{
    echo "\n\n" . get_class($exception);
    echo $exception->getMessage() . ' (' . $exception->getFile() . ':' . $exception->getLine() . ")";
    echo $exception->getTraceAsString();
    if ($exception->getPrevious() !== null) {
        displayException($exception->getPrevious());
    }
}
$appdeployer = new \zool\deploy\ApplicationDeployer(['zool' => ZOOL_PATH, 'app' => APP_PATH]);
$prevmtimehash = $argv[1];
$app = new Directory(BASE_PATH);
$files = $app->getFiles(true, ModuleDeployer::PHP_FILE_FILTER);
$mtime = '';
foreach ($files as $file) {
    if (!Strings::endsWidth($file, Deployment::DEPLOYMENT_DESCRIPTOR) && (Strings::contains($file, 'component') || Strings::contains($file, 'zool') || true)) {
        $mtime .= filemtime($file);
    }
}
$mtimehash = md5($mtime);
if ($prevmtimehash != $mtimehash) {
    try {
        $appdeployer->deploy(BASE_PATH);
    } catch (Exception $e) {
        echo "\n///////////////////  INCOMPLETE DEPLOYMENT  ///////////////////\n\n";
        displayException($e);
        //echo $mtimehash."\n";
    }
}
echo $mtimehash . "\n";
 protected function process($matches)
 {
     $name = $matches[1];
     foreach (Addendum::getConstPrefixes() as $namespace => $class) {
         if (Strings::startsWith($name, $class)) {
             $name = $namespace . $name;
             break;
         }
     }
     if (!defined($name)) {
         if (!defined($name)) {
             trigger_error("Constant '{$name}' used in annotation was not defined.");
             return false;
         }
     }
     return constant($name);
 }
 /**
  * Scans for declared components between declared classes.
  */
 private function scanComponents()
 {
     $enabledPrefixes = array_merge(self::$APPLICATIONS, array_keys($this->modules));
     foreach (get_declared_classes() as $class) {
         if (Strings::startsWithOneOf($class, $enabledPrefixes)) {
             $classReflection = new ReflectionAnnotatedClass($class);
             if (Reflection::inheritFrom($class, self::COMPONENT_PARENT_CLASS)) {
                 if (!$classReflection->hasAnnotation(self::COMPONENT_ANNOTATION)) {
                     $this->log->console("DEFINITION ERROR: {$class} extends Component, but has no annotation 'Component'");
                     continue;
                 }
                 $componentAnnotation = $classReflection->getAnnotation(self::COMPONENT_ANNOTATION);
                 $componentName = $componentAnnotation->value;
                 $this->log->console("Component:  \t {$componentName} -> {$class}");
                 if (array_key_exists($componentName, $this->components)) {
                     throw new DeploymentException("Multiple component definition: " . $this->components[$componentName]['class'] . " -> " . $class);
                 }
                 $this->components[$componentName] = [];
                 $this->components[$componentName]['class'] = $class;
                 $this->components[$componentName]['annotations'] = [];
                 foreach ($classReflection->getAllAnnotations() as $annot) {
                     $this->components[$componentName]['annotations'][] = $this->exportAnnotation($annot);
                 }
                 $this->components[$componentName]['properties'] = [];
                 $this->components[$componentName]['methods'] = [];
                 foreach ($classReflection->getProperties() as $reflectProp) {
                     $reflectAnnotations = $reflectProp->getAllAnnotations();
                     if (!empty($reflectAnnotations)) {
                         $this->components[$componentName]['properties'][$reflectProp->name] = [];
                         $this->components[$componentName]['properties'][$reflectProp->name]['annotations'] = [];
                         foreach ($reflectAnnotations as $propAnnot) {
                             $this->components[$componentName]['properties'][$reflectProp->name]['annotations'][] = $this->exportAnnotation($propAnnot);
                         }
                     }
                 }
                 foreach ($classReflection->getMethods() as $reflectMethod) {
                     $this->processMethod($componentName, $reflectMethod);
                 }
             }
         }
     }
 }
 /**
  * Loads locale file if exists.
  */
 private function loadLocale($lang, $fileBase, $messageKey)
 {
     if (!isset($this->messages[$lang])) {
         $this->messages[$lang] = [];
     }
     // load from file
     if (!isset($this->messsages[$lang][$fileBase])) {
         $localSuffix = '/' . self::LOCALE_DIRNAME . '/' . $lang . '/' . $fileBase . self::LOCALE_FILE_EXTENSION;
         $localeFile = new File(APP_PATH . $localSuffix);
         if ($localeFile->exists()) {
             // when the module not
             $this->messsages[$lang][$fileBase] = (require_once $localeFile->getPath());
         }
         if (!isset($this->messsages[$lang][$fileBase][$messageKey])) {
             foreach (Deployment::instance()->modules as $moduleName => $moduleDef) {
                 if ($moduleName == $fileBase) {
                     $moduleFileBase = Strings::splitBy($messageKey, self::MESSAGE_PATH_SEPARATOR)[0];
                     $this->tryToLoadLocaleFormModule($lang, $moduleName, $moduleDef['path'], $moduleFileBase);
                 }
             }
         }
         // could not loaded from anywhere
         if (!isset($this->messsages[$lang][$fileBase])) {
             $this->messsages[$lang][$fileBase] = [];
         }
     }
     $this->loadedFileBases[] = $fileBase;
 }