23 public static function start(&$config) {
24 self::$cacheDirectory = self::initialGetCacheDirectory ( $config );
26 Annotations::$config [
'cache'] =
new AnnotationCache (
$cacheDirectory .
'/annotations' );
27 self::register ( Annotations::getManager () );
37 self::$cacheDirectory = self::initialGetCacheDirectory ( $config );
43 $cacheSystem =
'Ubiquity\cache\system\ArrayCache';
45 if (! isset ( self::$cache )) {
46 if (isset ( $config [
"cache"] [
"system"] )) {
47 $cacheSystem = $config [
"cache"] [
"system"];
49 if (isset ( $config [
"cache"] [
"params"] )) {
50 $cacheParams = $config [
"cache"] [
"params"];
52 self::$cache =
new $cacheSystem (
$cacheDirectory, $postfix, $cacheParams );
60 $config [
"cache"] [
"directory"] =
"cache/";
67 return self::$cacheDirectory;
70 public static function checkCache(&$config, $silent =
false) {
71 $dirs = self::getCacheDirectories ( $config, $silent );
72 foreach ( $dirs as $dir ) {
73 self::safeMkdir ( $dir );
83 $modelsDir = str_replace (
"\\", DS, $config [
"mvcNS"] [
"models"] );
84 $controllersDir = str_replace (
"\\", DS, $config [
"mvcNS"] [
"controllers"] );
88 $controllersCacheDir = ROOT . DS .
$cacheDirectory . DS . $controllersDir;
92 return [
"annotations" => $annotationCacheDir,
"models" => $modelsCacheDir,
"controllers" => $controllersCacheDir,
"queries" => $queriesCacheDir,
"views" => $viewsCacheDir,
"seo" => $seoCacheDir,
"git" => $gitCacheDir ];
96 if (! is_dir ( $dir ))
97 return mkdir ( $dir, 0777,
true );
101 $cacheDirectories = self::checkCache ( $config );
102 $cacheDirs = [
"annotations",
"controllers",
"models",
"queries",
"views" ];
103 foreach ( $cacheDirs as $typeRef ) {
104 self::_clearCache ( $cacheDirectories, $type, $typeRef );
108 private static function _clearCache($cacheDirectories, $type, $typeRef) {
109 if ($type ===
"all" || $type === $typeRef)
113 public static function initCache(&$config, $type =
"all", $silent =
false) {
114 self::checkCache ( $config, $silent );
115 self::start ( $config );
116 if ($type ===
"all" || $type ===
"models")
117 self::initModelsCache ( $config,
false, $silent );
118 if ($type ===
"all" || $type ===
"controllers")
119 self::initRouterCache ( $config, $silent );
120 if ($type ===
"all" || $type ===
"rest")
121 self::initRestCache ( $config, $silent );
124 protected static function _getFiles(&$config, $type, $silent =
false) {
125 $typeNS = $config [
"mvcNS"] [$type];
126 $typeDir = ROOT . DS . str_replace (
"\\", DS, $typeNS );
128 echo \ucfirst ( $type ) .
" directory is " . ROOT . $typeNS .
"\n";
132 private static function register(AnnotationManager $annotationManager) {
133 $annotationManager->registry = array_merge ( $annotationManager->registry, [
'id' =>
'Ubiquity\annotations\IdAnnotation',
'manyToOne' =>
'Ubiquity\annotations\ManyToOneAnnotation',
'oneToMany' =>
'Ubiquity\annotations\OneToManyAnnotation',
134 'manyToMany' =>
'Ubiquity\annotations\ManyToManyAnnotation',
'joinColumn' =>
'Ubiquity\annotations\JoinColumnAnnotation',
'table' =>
'Ubiquity\annotations\TableAnnotation',
'transient' =>
'Ubiquity\annotations\TransientAnnotation',
'column' =>
'Ubiquity\annotations\ColumnAnnotation',
135 'joinTable' =>
'Ubiquity\annotations\JoinTableAnnotation',
'route' =>
'Ubiquity\annotations\router\RouteAnnotation',
'var' =>
'mindplay\annotations\standard\VarAnnotation',
'yuml' =>
'Ubiquity\annotations\YumlAnnotation',
'rest' =>
'Ubiquity\annotations\rest\RestAnnotation',
136 '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)
Starts the cache for production.
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")