Set up ACL rules with the current context

@return AclRules
328882
public function getContextualAcl()
    {
        $acl = $this->getRules();
        if (!$acl->hasRole($this->getContextId())) {
            $contextRoles = $this->getContext()->getRoles();
            if ($contextRoles instanceof RoleBucket) {
                $contextRoles = $contextRoles->toArray();
            }
            $acl->addRole(new Role($this->getContextId()), $contextRoles);
        }
        return $acl;
    }
38898
public function addChild(Acl $child)
    {
        $rules = $child->getRule();
        foreach ($rules as $rule) {
            $this->rules[] = $rule;
        }
        return $this;
    }
1359013
private function _initAcl()
    {
        $this->_acl = new \MUtil_Acl();

        if (get_class(self::$_instanceOfSelf)!=='Gems_Roles') {
            throw new \Gems_Exception_Coding("Don't use project specific roles file anymore, you can now do so by using the gems_roles tabel and setup->roles from the interface.");
        }
        // Probeer eerst uit db in te lezen met fallback als dat niet lukt
        try {
            $this->loadDbAcl();

        } catch (\Exception $e) {

            \Gems_Log::getLogger()->logError($e);

            // Reset all roles
            unset($this->_acl);
            $this->_acl = new \MUtil_Acl();

            //Voeg standaard rollen en privileges in
            $this->loadDefaultRoles();
            $this->loadDefaultPrivileges();
        }

        // Now allow 'master' all access, except for the actions that have the
        // nologin privilege (->the login action)
        if (!$this->_acl->hasRole('master')) {
            //Add role if not already present
            $this->_acl->addRole('master');
        }
        $this->_acl->allow('master');
        $this->_acl->deny('master', null, 'pr.nologin');
    }
393589
public function setupRules()
    {
        parent::setupRules();

        $this->rules->remove('symbol.selector.tag');
        $this->rules->add('symbol.selector.tag', new Rule(new RegexMatcher('/(?>[\s{};]|^)(?=(\w+)[^;}]*\{)/m'), [
            'context' => ['!symbol', '!string', '!number']
        ]));

        $this->rules->add('variable', new Rule(new RegexMatcher('/(\$[\w-]+)/'), ['context' => $this->everywhere()]));
    }
65327
private function createDocBlockContext()
    {
        $file = $this->descriptor->getFile();
        $namespaceAliases = $file ? $file->getNamespaceAliases()->getAll() : array();

        return new Context($this->descriptor->getNamespace(), $namespaceAliases);
    }
579498
private function createRules(Permission $permission): void
	{
		/* @var $rule Acl */
		foreach ($this->orm->acl->findAll() as $rule) {
			if ($rule->allowed) {
				$permission->allow($rule->role->name, $rule->resource->resource, $rule->privilege);
			} else {
				$permission->deny($rule->role->name, $rule->resource->resource, $rule->privilege);
			}
		}
	}
745866
public function reload(): WebAcl {
        $fedora         = $this->res->getFedora();
        $resUri         = $this->res->getUri(true);
        $aclUri         = $this->res->getAclUrl();
        $this->resRules = [];
        $this->extRules = [];

        if ($aclUri) {
            $query   = new SimpleQuery(self::QUERY, [$resUri, $aclUri]);
            $results = $fedora->runQuery($query);
            $rules   = self::initRules($results, $fedora, $aclUri);
            foreach ($rules as $r) {
                if ($r->hasResource($resUri)) {
                    $this->resRules[] = $r;
                } else {
                    $this->extRules[] = $r;
                }
            }
        }
        return $this;
    }
1031467
def set_acl(self, role, users):
        
        acl_updates = [{"user": user, "role": role} for user in users]
        r = fapi.update_repository_method_acl(
            self.namespace, self.name, self.snapshot_id,
            acl_updates, self.api_url
        )
        fapi._check_response_code(r, 200)
434193
public function getAdditionalAccountRules()
    {
        $rules = $this->getEnableLoginAttributeRules();
        if ($this->getPasswordIsSeperate()) {
            $rules = array_merge($rules, $this->getPasswordHashRules());
        }
        return $rules;
    }
596695
public function setupRules()
    {
        parent::setupRules();

        $this->rules->rule('symbol.selector.class')->setContext($this->outside());
        $this->rules->rule('symbol.selector.tag')->setContext($this->outside());
        $this->rules->rule('symbol.selector.class.pseudo')->setContext($this->outside());
        $this->rules->rule('symbol.selector.id')->setContext($this->outside());

        $this->rules->rule('constant.color')->setContext(['!string', '!symbol', '!comment']);
        $this->rules->rule('number')->setContext(['!comment', '!symbol', '!constant', '!string', '!variable']);
        $this->rules->rule('call')->setContext(['!comment', '!symbol', '!constant', '!string']);

        $this->rules->add('operator.self', new Rule(new SubStringMatcher('&'), ['context' => $this->everywhere()]));

        $this->rules->add(
            'comment.multiline',
            new Rule(new CommentMatcher(['//'], []), ['context' => $this->rules->rule('comment')->validator])
        );
    }
290528
public static function rules()
    {
        if (self::$adminRules === null) {
            self::$adminRules = array();

            // Map over the array calling add_rule_for_controller on each
            $classes = CMSMenu::get_cms_classes(null, true, CMSMenu::URL_PRIORITY);
            array_map(array(__CLASS__, 'add_rule_for_controller'), $classes);
        }
        return self::$adminRules;
    }
1143747
protected function getAclSddlFlags(Acl $acl)
    {
        $flags = '';

        foreach ($this->aclFlagMap as $flag => $name) {
            $name = $acl->getSddlIdentifier().$name;
            if ($this->controlFlags->has(ControlFlags::FLAG[$name])) {
                $flags .= $flag;
            }
        }

        return $flags;
    }
241717
private function getAcl(): ?array {

		if (!$this->issetCache('acl')) {
		
			$query =
				'SELECT r.*, m.name AS module_name' .
				' FROM `rules` AS r' .
				' INNER JOIN `acl` AS a ON a.rule_id = r.id'.
				' INNER JOIN `modules` AS m ON r.module_id = m.id'.
				' WHERE a.group_id = ?';
			
			$this->db->setQuery($query);
			$this->setCache('acl', $this->db->loadObjectList($this->groupId));

		}

		return $this->getCache('acl');
		
	}
1023326
public function setupRules()
    {
        $this->rules->addMany([
            'keyword' => new Rule(new WordMatcher([
                'auto', 'break', 'case', 'const', 'continue', 'default', 'do', 'else', 'enum', 'extern', 'for', 'goto',
                'if', 'register', 'return', 'sizeof', 'static', 'struct', 'switch', 'typedef', 'union', 'volatile',
                'while',
            ])),

            'meta.newline' => new CloseRule(new RegexMatcher('/()\R/m'), [
                'factory' => new TokenFactory(TerminatorToken::class),
                'context' => ['!operator.escape', '*string', '*call.preprocessor'],
                'closes'  => ['string.double', 'preprocessor'],
            ]),

            'preprocessor' => new OpenRule(new RegexMatcher('/^(#)/m'), [
                'context' => Validator::everywhere(),
                'priority' => -1
            ]),

            'call' => [
                'preprocessor' => new Rule(new RegexMatcher('/^#\s*(\w+)\b/m'), [
                    'context' => ['preprocessor']
                ]),
                new Rule(new RegexMatcher('/([a-z_]\w*)\s*\(/i'), ['priority' => -1]),
            ],

            'operator.escape' => new Rule(new RegexMatcher('/(\\\(?:\R|.|[0-7]{3}|x\x{2}))/s'), [
                'context' => Validator::everywhere()
            ]),

            'keyword.format' => new Rule(
                new RegexMatcher('/(%[diuoxXfFeEgGaAcspn%][-+#0]?(?:[0-9]+|\*)?(?:\.(?:[0-9]+|\*))?)/'), [
                    'context' => ['string']
                ]
            ),

            'string' => array_merge([
                new Rule(new RegexMatcher('/(<.*?>)/'), [
                    'context' => ['preprocessor']
                ])
            ], CommonFeatures::strings(['single' => '\'', 'double' => '"'], [
                'context' => ['!operator.escape', '!comment', '!string'],
            ])),

            'symbol.type' => [
                new Rule(new RegexMatcher('/(\w+)(?:\s+|\s*\*\s*)\w+\s*[=();,]/'), ['name' => 'universal']),
                new Rule(new WordMatcher(['int', 'float', 'double', 'char', 'void', 'long', 'short', 'signed', 'unsigned']), ['name' => 'builtin'])
            ],

            'comment' => [
                new Rule(new CommentMatcher(['//'], [['/*', '*/']]), ['priority' => 2])
            ],

            'variable.property' => new Rule(new RegexMatcher('/(?=(?:\w|\)|\])\s*(?:->|\.)\s*([a-z_]\w*))/'), ['priority' => 0]),

            'number' => new Rule(new RegexMatcher('/\b(-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)[ful]*)\b/i')),
            'operator' => [
                'punctuation' => new Rule(new RegexMatcher('/([;,])/'), ['priority' => 0]),
                new Rule(new RegexMatcher('/([*&])/'), ['priority' => 0]),
                new Rule(new RegexMatcher('/([!+\-\/*&|^<>=]{1,2}=?)/'), ['priority' => 0])
            ],

            'language.c' => [
                new Rule(new RegexMatcher('/^#define\s+\w+(.*?)(?>[^\\\]\r\n|[^\\\\\r]\n|\Z)/sim'), [
                    'factory' => new TokenFactory(LanguageToken::class),
                    'inject'  => $this,
                    'context' => ['preprocessor'],
                    'priority' => 10
                ]),
            ]
        ]);
    }
1284206
public function setRules( $rules )
    {
        $this->rules = array();

        foreach ( $rules as $rule )
        {
            $this->addRule( $rule );
        }

        return $this;
    }
845031
protected function addRules()
    {
        try {
            (new Rbac())->add($this->authManager);
            return $this->returnSuccess(Yii::t('podium/flash', 'Access roles have been created.'));
        } catch (Exception $e) {
            return $this->returnError($e->getMessage(), __METHOD__,
                Yii::t('podium/flash', 'Error during access roles creating')
            );
        }
    }
59718
public function processAcls(array &$configuration)
    {
        if (!isset($configuration['acls'])) {
            return;
        }
        $newRolesConfiguration = isset($configuration['roles']) ? $configuration['roles'] : array();
        foreach ($configuration['acls'] as $roleIdentifier => $aclConfiguration) {
            $roleIdentifier = $this->expandRoleIdentifier($roleIdentifier);
            if (!isset($newRolesConfiguration[$roleIdentifier])) {
                $newRolesConfiguration[$roleIdentifier] = array();
            }
            if (!isset($newRolesConfiguration[$roleIdentifier]['privileges'])) {
                $newRolesConfiguration[$roleIdentifier]['privileges'] = array();
            }
            foreach ($aclConfiguration as $resourceType => $permissions) {
                if ($resourceType !== 'methods' && $resourceType !== 'entities') {
                    $this->showWarning('Resource type "' . $resourceType . '" is not supported...');
                    continue;
                }
                foreach ($permissions as $resourceName => $permission) {
                    $newRolesConfiguration[$roleIdentifier]['privileges'][] = array('privilegeTarget' => $resourceName, 'permission' => $permission);
                }
            }
        }
        unset($configuration['acls']);
        $configuration['roles'] = $newRolesConfiguration;
    }