Retrieve rules data from DB and inject it into ACL

@return Mage_Api2_Model_Acl
766149
protected function _setRules()
    {
        $resources = $this->getResources();

        /** @var Mage_Api2_Model_Resource_Acl_Global_Rule_Collection $rulesCollection */
        $rulesCollection = Mage::getResourceModel('api2/acl_global_rule_collection');
        foreach ($rulesCollection as $rule) {
            /** @var Mage_Api2_Model_Acl_Global_Rule $rule */
            if (Mage_Api2_Model_Acl_Global_Rule::RESOURCE_ALL === $rule->getResourceId()) {
                if (in_array($rule->getRoleId(), Mage_Api2_Model_Acl_Global_Role::getSystemRoles())) {
                    /** @var Mage_Api2_Model_Acl_Global_Role $role */
                    $role = $this->_getRolesCollection()->getItemById($rule->getRoleId());
                    $privileges = $this->_getConfig()->getResourceUserPrivileges(
                        $this->_resourceType,
                        $role->getConfigNodeName()
                    );

                    if (!array_key_exists($this->_operation, $privileges)) {
                        continue;
                    }
                }

                $this->allow($rule->getRoleId());
            } elseif (in_array($rule->getResourceId(), $resources)) {
                $this->allow($rule->getRoleId(), $rule->getResourceId(), $rule->getPrivilege());
            }
        }

        return $this;
    }
631445
public function rules()
    {

        $name = $this->route()->getName();
        $tbl = ( str_contains($name, 'role') ) ? 'roles' : 'permissions';

       return [
            'name' => 'required|unique:'.$tbl.'|max:255|min:4',
            'slug' => 'required|unique:'.$tbl.'|max:255|min:4',
        ];

    }
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;
    }
779822
public function getRules()
    {
        if (!$this->rules) {
            return '[]';
        }
        $results = '[' . PHP_EOL;

        foreach ($this->getSchemaParser()->toArray() as $column => $value) {
            $results .= "\t\t'{$column}'\t=>'\t{$value}'," . PHP_EOL;
        }

        return $results . "\t" . ']';
    }
915888
protected function getRules()
    {
        if ($this->compiledRules === null) {
            $rules = array();

            foreach ($this->ruleFiles as $file) {
                $rules += require $file;
            }

            $this->compiledRules = $this->compiler->compile($rules);
        }

        return $this->compiledRules;
    }
1013908
public function rules()
	{
		$data = array();
		foreach ($this->validators as $validate)
		{
			$attrs = $this->klass->getStaticPropertyValue($validate);

			foreach (wrap_strings_in_arrays($attrs) as $attr)
			{
				$field = $attr[0];

				if (!isset($data[$field]) || !is_array($data[$field]))
					$data[$field] = array();

				$attr['validator'] = $validate;
				unset($attr[0]);
				array_push($data[$field],$attr);
			}
		}
		return $data;
	}
904988
private function loadModelRules()
    {
        foreach ($this->rules['modelRules'] as $modelClass => $modelPolicy) {
            $resourceId = call_user_func_array($this->config['modelResourceGenerator'], [$modelClass]);
            $this->acl->addResource(new Resource($resourceId));
            $modelAccessPolicy = [];
            if (isset($modelPolicy['access'])) {
                $modelAccessPolicy = $modelPolicy['access'];
            }
            foreach ($modelAccessPolicy as $ruleSet => $privileges) {
                foreach ($privileges as $privilege) {
                    $this->enforceRuleset($ruleSet, ['privileges' => $privilege, 'resources' => $resourceId]);
                }
            }
            $this->loadModelFieldPolicy($modelClass, $modelPolicy);
        }
    }
539018
public function getRule()
    {
        $rules = [];
        if ($this->isRequired()) {
            $rules[] = 'required';
        }
        if ($this->getValidations()) {
            $rules[] = $this->getValidations();
        }

        $rules = join('|', $rules);
        return $rules;
    }
1110821
public function buildAcl()
    {
        if ($this->builded) {
            return $this;
        }
        $config = $this->getConfig();
        $this->buildCommonRoles()->deny(self::ROLE_PUBLIC);
        foreach ($config['controller'] as $controller => $roles) {
            $this->addResource($controller);
            $this->allows($roles, $controller);
        }
        foreach ($config['action'] as $controller => $actions) {
            foreach ($actions as $action => $roles) {
                $resource = $this->buildResource($controller, $action);
                if (!$roles) {
                    $this->addResource($resource, $controller);
                } else {
                    $this->addResource($resource);
                }
                $this->allows($roles, $resource);
            }
        }
        foreach ($config['admin'] as $admin) {
            if (!$this->hasRole($admin)) {
                $this->addRole($admin, [self::ROLE_ADMIN, self::ROLE_LOGGED, self::ROLE_PUBLIC]);
            }
            $this->allow($admin);
        }
        
        $this->builded = true;
        return $this;
    }
1190947
public function getRuleList()
    {
        $rows = (new Query())
            ->select(['name'])
            ->from($this->manager->ruleTable)
            ->all();

        return ArrayHelper::map($rows, 'name', 'name');
    }
117058
protected function getRules()
	{
		if ( ! $this->hasScope())
		{
			return $this->replaceBindings($this->rules);
		}

		// Set default rules
		$resultingRules = isset($this->rules[$this->getDefaultScope()]) ? $this->rules[$this->getDefaultScope()] : [];

		foreach ($this->scopes as $scope)
		{
			if ( ! isset($this->rules[$scope])) continue;

			$resultingRules = array_merge($resultingRules, $this->rules[$scope]);
		}

		return $this->replaceBindings($resultingRules);
	}
1331789
public function getChildACL()
    {
        $acl = [
            [
                'privilege' => '{DAV:}read',
                'principal' => $this->getOwner(),
                'protected' => true,
            ],

            [
                'privilege' => '{DAV:}read',
                'principal' => $this->getOwner().'/calendar-proxy-write',
                'protected' => true,
            ],
            [
                'privilege' => '{DAV:}read',
                'principal' => $this->getOwner().'/calendar-proxy-read',
                'protected' => true,
            ],
        ];
        if (empty($this->calendarInfo['{http://sabredav.org/ns}read-only'])) {
            $acl[] = [
                'privilege' => '{DAV:}write',
                'principal' => $this->getOwner(),
                'protected' => true,
            ];
            $acl[] = [
                'privilege' => '{DAV:}write',
                'principal' => $this->getOwner().'/calendar-proxy-write',
                'protected' => true,
            ];
        }

        return $acl;
    }
1164588
public static function setupAcl()
    {
        $acl = new \Mmi\Security\Acl;
        $aclData = (new CmsAclQuery)
            ->join('cms_role')->on('cms_role_id')
            ->find();
        foreach ($aclData as $aclRule) { /* @var $aclData \Cms\Orm\CmsAclRecord */
            $resource = '';
            if ($aclRule->module) {
                $resource .= $aclRule->module . ':';
            }
            if ($aclRule->controller) {
                $resource .= $aclRule->controller . ':';
            }
            if ($aclRule->action) {
                $resource .= $aclRule->action . ':';
            }
            $access = $aclRule->access;
            if ($access == 'allow' || $access == 'deny') {
                $acl->$access($aclRule->getJoined('cms_role')->name, trim($resource, ':'));
            }
        }
        return $acl;
    }
1365939
public function get($calendarId, $ruleId, $optParams = array()) {
      $params = array('calendarId' => $calendarId, 'ruleId' => $ruleId);
      $params = array_merge($params, $optParams);
      $data = $this->__call('get', array($params));
      if ($this->useObjects()) {
        return new AclRule($data);
      } else {
        return $data;
      }
    }
399332
public function rules()
    {
        $rules = [];
        foreach ($this->assocConfig(true) as $key => $data) {
            if (empty($data['rules'])) {
                continue;
            }
            $rules[str_replace('.', '|', $key)] = $data['rules'];
        }

        return $rules;
    }
92299
public function getCanAttribute()
    {
        $permissions = [];
        foreach (Permission::all() as $permission) {
            if (Auth::check() && Auth::user()->can($permission->name)) {
                $permissions[$permission->name] = true;
            } else {
                $permissions[$permission->name] = false;
            }
        }
        return $permissions;
    }
502872
public function rules()
    {

        $id = ( $this->route('permission') ) ?: $this->route('role');

        $tbl = str_plural( $this->route()->parameterNames()[0] );

        return [
            'slug' => 'required|unique:'.$tbl.',slug,'.$id.'|max:255|min:4',
            'name' => 'required|unique:'.$tbl.',name,'.$id.'|max:255|min:4',            
        ];

    }