7use Ubiquity\utils\base\UArray;
21 protected static function initRestCache(array &$config,
bool $silent =
false): void {
23 $files = self::getControllersFiles ( $config );
24 foreach ( $files as $file ) {
25 if (is_file ( $file )) {
28 $parser->parse ( $controller, $config );
29 if ($parser->isRest ()) {
30 $restCache = \array_merge($restCache, $parser->asArray());
34 self::$cache->store (
'controllers/rest', $restCache,
'controllers' );
36 echo
"Rest cache reset\n";
42 $restCache = self::getRestCache ();
43 foreach ( $restCache as $controllerClass => $restAttributes ) {
44 if (isset ( $restCache [$controllerClass] )) {
45 $result [$controllerClass] = [
'restAttributes' => $restAttributes,
'routes' => self::getControllerRoutes ( $controllerClass,
true ) ];
52 if (self::$cache->exists (
'controllers/rest' )) {
53 return self::$cache->fetch(
'controllers/rest');
55 throw new RestException (
'Rest cache entry `' . self::$cache->getEntryKey (
'controllers/rest' ) .
"` is missing.\nTry to Re-init Rest cache." );
59 $cacheControllerClass = self::getRestCacheController ( $controllerClass );
60 if (isset ( $cacheControllerClass )) {
61 return $cacheControllerClass [
'resource'];
67 $cache = self::getRestCache ();
68 if (isset ( $cache [$controllerClass] )) {
69 return $cache [$controllerClass];
Manipulates class and namespace names Ubiquity\cache$ClassUtils This class is part of Ubiquity.
static getClassFullNameFromFile($filePathName, $backSlash=false)
get the full name (name \ namespace) of a class from its file path result example: (string) "I\Am\The...
Ubiquity\cache\parser$RestControllerParser This class is part of Ubiquity.
static initRestCache(array &$config, bool $silent=false)
static getRestCacheController(string $controllerClass)
static getRestResource(string $controllerClass)
Exceptions for Rest service.