24 public static function start(&$config) {
25 self::$cacheDirectory=self::initialGetCacheDirectory($config);
27 Annotations::$config[
'cache']=
new AnnotationCache(
$cacheDirectory .
'/annotations');
28 self::register(Annotations::getManager());
33 self::$cacheDirectory=self::initialGetCacheDirectory($config);
39 $cacheSystem=
'Ubiquity\cache\system\ArrayCache';
41 if (!isset(self::$cache)) {
42 if (isset($config[
"cache"][
"system"])) {
43 $cacheSystem=$config[
"cache"][
"system"];
45 if (isset($config[
"cache"][
"params"])) {
46 $cacheParams=$config[
"cache"][
"params"];
56 $config[
"cache"][
"directory"]=
"cache/";
63 return self::$cacheDirectory;
66 public static function checkCache(&$config, $silent=
false) {
67 $dirs=self::getCacheDirectories($config, $silent);
68 foreach ( $dirs as $dir ) {
69 self::safeMkdir($dir);
79 $modelsDir=str_replace(
"\\", DS, $config[
"mvcNS"][
"models"]);
80 $controllersDir=str_replace(
"\\", DS, $config[
"mvcNS"][
"controllers"]);
84 $controllersCacheDir=ROOT . DS .
$cacheDirectory . DS . $controllersDir;
86 return [
"annotations" => $annotationCacheDir,
"models" => $modelsCacheDir,
"controllers" => $controllersCacheDir,
"queries" => $queriesCacheDir,
"views" => $viewsCacheDir ];
91 return mkdir($dir, 0777,
true);
94 public static function clearCache(&$config, $type=
"all") {
95 $cacheDirectories=self::checkCache($config);
96 $cacheDirs=[
"annotations",
"controllers",
"models",
"queries",
"views" ];
97 foreach ( $cacheDirs as $typeRef ) {
98 self::_clearCache($cacheDirectories, $type, $typeRef);
102 private static function _clearCache($cacheDirectories, $type, $typeRef) {
103 if ($type ===
"all" || $type === $typeRef)
107 public static function initCache(&$config, $type=
"all", $silent=
false) {
108 self::checkCache($config, $silent);
109 self::start($config);
110 if ($type ===
"all" || $type ===
"models")
111 self::initModelsCache($config,
false, $silent);
112 if ($type ===
"all" || $type ===
"controllers")
113 self::initRouterCache($config, $silent);
114 if ($type ===
"all" || $type ===
"rest")
115 self::initRestCache($config, $silent);
118 protected static function _getFiles(&$config, $type, $silent=
false) {
119 $typeNS=$config[
"mvcNS"][$type];
120 $typeDir=ROOT . DS . str_replace(
"\\", DS, $typeNS);
122 echo \ucfirst($type) .
" directory is " . ROOT . $typeNS .
"\n";
126 private static function register(AnnotationManager $annotationManager) {
127 $annotationManager->registry=array_merge($annotationManager->registry, [
'id' =>
'Ubiquity\annotations\IdAnnotation',
'manyToOne' =>
'Ubiquity\annotations\ManyToOneAnnotation',
'oneToMany' =>
'Ubiquity\annotations\OneToManyAnnotation',
'manyToMany' =>
'Ubiquity\annotations\ManyToManyAnnotation',
'joinColumn' =>
'Ubiquity\annotations\JoinColumnAnnotation',
'table' =>
'Ubiquity\annotations\TableAnnotation',
'transient' =>
'Ubiquity\annotations\TransientAnnotation',
'column' =>
'Ubiquity\annotations\ColumnAnnotation',
'joinTable' =>
'Ubiquity\annotations\JoinTableAnnotation',
'route' =>
'Ubiquity\annotations\router\RouteAnnotation',
'var' =>
'mindplay\annotations\standard\VarAnnotation',
'yuml' =>
'Ubiquity\annotations\YumlAnnotation',
'rest' =>
'Ubiquity\annotations\rest\RestAnnotation',
'authorization' =>
'Ubiquity\annotations\rest\AuthorizationAnnotation' ]);
static glob_recursive($pattern, $flags=0)
static _getFiles(&$config, $type, $silent=false)
static getCacheInstance(&$config, $cacheDirectory, $postfix)
static _clearCache($cacheDirectories, $type, $typeRef)
static cleanPathname($path)
static startProd(&$config)
static initialGetCacheDirectory(&$config)
static getCacheDirectory()
static checkCache(&$config, $silent=false)
static getCacheDirectories(&$config, $silent=false)
static initCache(&$config, $type="all", $silent=false)
static deleteAllFilesFromFolder($folder)
static clearCache(&$config, $type="all")