23 public static function start(): void {
25 self::$aclList->
init();
42 return isset(self::$aclList) && (self::$aclList instanceof
AclList);
51 self::$aclList->setProviders($providers);
52 if (\count($providers) > 0) {
53 self::$aclList->loadAcls();
54 self::$aclList->loadRoles();
55 self::$aclList->loadResources();
56 self::$aclList->loadPermissions();
65 $sProviders = self::$aclList->getProviders();
66 self::$aclList->clear();
68 foreach ($sProviders as $prov) {
69 if ($selectedProviders ===
'*' || (\is_array($selectedProviders) && \array_search(\get_class($prov), $selectedProviders) !==
false)) {
73 self::initFromProviders($providers);
74 self::$aclList->setProviders($sProviders);
83 return self::$aclList->getProvider($providerClass);
88 $aclList = self::getAclList();
89 if (isset($aclList)) {
90 foreach ($aclList->getProviders() as $prov) {
91 $result += $prov->getModelClassesSwap();
98 $providers = self::$aclList->getProviders();
100 foreach ($providers as $prov) {
101 if ($prov instanceof $providerClass) {
105 self::$aclList->setProviders($filter);
106 self::$providersPersistence = $providers;
110 self::$aclList->setProviders(self::$providersPersistence);
125 return AclDAOProvider::initializeProvider($config,$dbOffset,$classes);
136 public static function initCache(array &$config,
bool $silent=
false): void {
137 self::cacheOperation($config, $silent, function ($parser) {
139 },
"ACLs cache reset\n");
147 return self::cacheOperation($config, true, function ($parser) {
148 return $parser->cacheUpdated();
152 private static function cacheOperation(array &$config,
bool $silent, $operation, $message=
null) {
153 if (!self::isStarted()) {
155 self::initFromProviders([
159 self::filterProviders(AclCacheProvider::class);
160 self::reloadFromSelectedProviders([]);
161 self::registerAnnotations();
162 $files = \Ubiquity\cache\CacheManager::getControllersFiles($config, $silent);
165 foreach ($files as $file) {
166 if (\is_file($file)) {
167 $controller = ClassUtils::getClassFullNameFromFile($file);
169 $parser->parse($controller);
170 }
catch (\Exception $e) {
177 $result = $operation($parser);
178 self::removefilterProviders();
179 self::reloadFromSelectedProviders();
187 CacheManager::getAnnotationsEngineInstance()->registerAcls();
Manager for caches (Router, Rest, models).
Manipulates class and namespace names Ubiquity\cache$ClassUtils This class is part of Ubiquity.
Ubiquity\exceptions$AclException This class is part of Ubiquity.
Ubiquity\security\acl\cache$AclControllerParser This class is part of Ubiquity.
Ubiquity\security\acl\models$AclList This class is part of Ubiquity.
Ubiquity\security\acl\persistence$AclCacheProvider This class is part of Ubiquity.
Load and save Acls with a database using DAO.
static reloadFromSelectedProviders($selectedProviders=' *')
static start()
Create AclList with default roles and resources.
static filterProviders(string $providerClass)
static checkCache(array &$config)
static getProvider(string $providerClass)
static registerAnnotations()
static getModelClassesSwap()
static startWithCacheProvider()
Start the Acls with AclCacheProvider (for attributes or annotations).
static cacheOperation(array &$config, bool $silent, $operation, $message=null)
static initializeDAOProvider(array &$config, string $dbOffset='default', array $classes=[])
Initializes AclDAOProvider and creates ACL tables in the specified dbOffset.
static initCache(array &$config, bool $silent=false)
Initialize acls cache with controllers annotations.
static initFromProviders(?array $providers=[])
Load acls, roles, resources and permissions from providers.
static isStarted()
Check whether the Acl service is started.
static removefilterProviders()
Ubiquity\security\acl\persistence$AclProviderInterface This class is part of Ubiquity.