Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
DiManager.php
Go to the documentation of this file.
1<?php
2
4
6
17class DiManager {
18 protected static $key = "controllers/di/";
19
26 public static function init(&$config) {
27 $controllers = CacheManager::getControllers ();
28 foreach ( $controllers as $controller ) {
29 CacheManager::$cache->remove ( self::getControllerCacheKey ( $controller ) );
30 $parser = new DiControllerParser ();
31 $parser->parse ( $controller, $config );
32 $injections = $parser->getInjections ();
33 if (\count ( $injections ) > 0) {
34 self::store ( $controller, $injections );
35 }
36 }
37 }
38
39 protected static function store($controller, $injections) {
40 CacheManager::$cache->store ( self::getControllerCacheKey ( $controller ), $injections );
41 }
42
43 public static function fetch($controller) {
44 $key = self::getControllerCacheKey ( $controller );
45 if (CacheManager::$cache->exists ( $key )) {
46 return CacheManager::$cache->fetch ( $key );
47 }
48 return false;
49 }
50
51 protected static function getControllerCacheKey($classname) {
52 if (\is_object ( $classname )) {
53 $classname = \get_class ( $classname );
54 }
55 return self::$key . \str_replace ( "\\", \DS, $classname );
56 }
57}
58
Manager for caches (Router, Rest, models).
Parse the controllers for dependency injections.
Manage dependency injection.
Definition DiManager.php:17
static getControllerCacheKey($classname)
Definition DiManager.php:51
static store($controller, $injections)
Definition DiManager.php:39
static init(&$config)
Initialize dependency injection cache To use in dev only!
Definition DiManager.php:26