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 "annotations" => $annotationCacheDir,
93 "models" => $modelsCacheDir,
94 "controllers" => $controllersCacheDir,
95 "queries" => $queriesCacheDir,
96 "views" => $viewsCacheDir,
102 if (! is_dir ( $dir ))
103 return mkdir ( $dir, 0777,
true );
107 $cacheDirectories = self::checkCache ( $config );
115 foreach ( $cacheDirs as $typeRef ) {
116 self::_clearCache ( $cacheDirectories, $type, $typeRef );
120 private static function _clearCache($cacheDirectories, $type, $typeRef) {
121 if ($type ===
"all" || $type === $typeRef)
125 public static function initCache(&$config, $type =
"all", $silent =
false) {
126 self::checkCache ( $config, $silent );
127 self::start ( $config );
128 if ($type ===
"all" || $type ===
"models")
129 self::initModelsCache ( $config,
false, $silent );
130 if ($type ===
"all" || $type ===
"controllers")
131 self::initRouterCache ( $config, $silent );
132 if ($type ===
"all" || $type ===
"rest")
133 self::initRestCache ( $config, $silent );
136 protected static function _getFiles(&$config, $type, $silent =
false) {
137 $typeNS = $config [
"mvcNS"] [$type];
138 $typeDir = ROOT . DS . str_replace (
"\\", DS, $typeNS );
140 echo \ucfirst ( $type ) .
" directory is " . ROOT . $typeNS .
"\n";
144 private static function register(AnnotationManager $annotationManager) {
145 $annotationManager->registry = array_merge ( $annotationManager->registry, [
146 'id' =>
'Ubiquity\annotations\IdAnnotation',
147 'manyToOne' =>
'Ubiquity\annotations\ManyToOneAnnotation',
148 'oneToMany' =>
'Ubiquity\annotations\OneToManyAnnotation',
149 'manyToMany' =>
'Ubiquity\annotations\ManyToManyAnnotation',
150 'joinColumn' =>
'Ubiquity\annotations\JoinColumnAnnotation',
151 'table' =>
'Ubiquity\annotations\TableAnnotation',
152 'transient' =>
'Ubiquity\annotations\TransientAnnotation',
153 'column' =>
'Ubiquity\annotations\ColumnAnnotation',
154 'joinTable' =>
'Ubiquity\annotations\JoinTableAnnotation',
155 'route' =>
'Ubiquity\annotations\router\RouteAnnotation',
156 'var' =>
'mindplay\annotations\standard\VarAnnotation',
157 'yuml' =>
'Ubiquity\annotations\YumlAnnotation',
158 'rest' =>
'Ubiquity\annotations\rest\RestAnnotation',
159 '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")