Fetch all the trees that we have permission to access.

@return Tree[]
338202
public static function getAll(): array
    {
        if (empty(self::$trees)) {
            self::$trees = self::all()->all();
        }

        return self::$trees;
    }
1109310
public function getParents()
    {
        $parents = [];
        if ($this->parent && !$this->parent instanceof Root) {
            $parents = $this->parent->getParents();
            $parents[] = $this->parent;
        }

        return $parents;
    }
665575
private function getParentPermissions() : array
    {
        $result = [];
        foreach ($this->table->associations() as $association) {
            if (! $this->isSupportedJoinAssociation($association)) {
                continue;
            }

            if (! $this->isParentModuleAssociation($association)) {
                continue;
            }

            $foreignKey = $association->getForeignKey();
            Assert::string($foreignKey);

            $field = sprintf('%s IN', $foreignKey);
            $result[$field] = $this->getPermissionsByModel($this->getModelByAssociation($association));
        }

        return $result;
    }
926250
private function _getRoots()
    {
        $directories = [];

        if (is_string($this->module->root)) {
            $root = Yii::getAlias($this->module->root);
            if ($this->module->scanRootParentDirectory) {
                $root = dirname($root);
            }

            $directories[] = $root;
        } elseif (is_array($this->module->root)) {
            foreach ($this->module->root as $root) {
                $directories[] = Yii::getAlias($root);
            }
        } else {
            throw new InvalidConfigException('Invalid `root` option value!');
        }

        return $directories;
    }
861980
public function getAllRootIds()
    {
        $entityClass = $this->getEntityClass();

        $query  = $this->getObjectManager()->createQuery('SELECT DISTINCT c.root FROM ' . $entityClass . ' c');
        $result = $query->getResult();

        $rootIds = array();
        foreach ($result as $resultArray) {
            $rootIds[] = $resultArray['root'];
        }

        return $rootIds;
    }
428851
public function getPermissionsSlugList() {

		$slugList	= [];
		$idList		= [];

		// TODO: Use roles hierarchy recursively to get child roles

		if( !empty( $this->gridCache ) ) {

			return $this->getGridCacheAttribute( 'permissionsSlugList' );
		}
		else {

			// Generate L0 Slugs and Ids List
			$permissions = $this->permissions;

			foreach( $permissions as $permission ) {

				if( !in_array( $permission->slug, $slugList ) ) {

					array_push( $slugList, $permission->slug );

					if( $permission->group ) {

						array_push( $idList, $permission->id );
					}
				}
			}

			// Add child permission slugs recursively till all leaf nodes get exhausted.
			while( count( $idList ) > 0 ) {

				$permissions = Permission::findGroupPermissions( $idList );

				$idList = [];

				foreach( $permissions as $permission ) {

					if( !in_array( $permission->slug, $slugList ) ) {

						array_push( $slugList, $permission->slug );

						if( $permission->group ) {

							array_push( $idList, $permission->id );
						}
					}
				}

				if( count( $idList ) == 0 ) {

					break;
				}
			};
		}

		return $slugList;
	}
544159
private function getWhereClause(): array
    {
        $result = array_merge($this->getOwnerFields(), $this->getBelongTo(), $this->getPermissions());
        $result = array_merge($result, $this->getParentPermissions(), $this->getParentJoinsWhereClause());
        $result = array_merge_recursive($result, $this->getSupervisorWhereClause());

        return $result;
    }
94904
private function getRootNodes()
    {
        $output = array();
        foreach( $this->nodes as $node )
            if (! $node->parentCount() )
                $output[] = $node;
        return $output;
    }
427821
public function getItems(): array
    {
        $available = [];
        $assigned = [];

        foreach (array_keys($this->manager->getRoles()) as $name) {
            $available[$name] = 'role';
        }

        foreach (array_keys($this->manager->getPermissions()) as $name) {
            if ($name[0] != '/') {
                $available[$name] = 'permission';
            }
        }

        foreach ($this->manager->getAssignments($this->userId) as $item) {
            $assigned[$item->roleName] = $available[$item->roleName];
            unset($available[$item->roleName]);
        }

        return [
            'available' => $available,
            'assigned' => $assigned,
        ];
    }
770478
private function getPermissionActions()
    {
        $actions = [];

        /**
         * @var $route \Symfony\Component\Routing\Route
         */
        foreach ($this->get('router')->getRouteCollection()->all() as $name => $route) {
            if ($route->hasOption('require_admin_permission')) {
                list(, $action) = explode('.', $route->getOption('require_admin_permission'));
                $actions[$action] = [
                    'id'   => $action,
                    'name' => $action
                ];
            }
        }

        ksort($actions);

        return array_values($actions);
    }
1372584
public function getPermissions()
    {
        $permissions = [[], []];

        foreach ($this->roles as $role) {
            $permissions[] = $role->getPermissions();
        }

        return call_user_func_array('array_merge', $permissions);
    }
284236
protected function loadTreeFromCache(): ?array
    {
        $cachedTree = $this->cache->getItem('ordermind.logauth.permissions');
        if ($cachedTree->isHit()) {
            return $cachedTree->get();
        }

        return null;
    }
151641
public function getRolesWithPermissions(): Collection
    {
        return $this->roleRepository->makeQuery()
            ->with('permissions')
            ->notSuperAdmin()
            ->orderBy('name')
            ->get()
            ->map(function (HCAclRole $role) {
                return [
                    'id' => $role->id,
                    'role' => $role->name,
                    'slug' => $role->slug,
                    'permissions' => $role->permissions->pluck('id')->all(),
                ];
            });
    }
1372000
public function getAccessListItems()
    {
        $obj = $this->getPermissionAccessObject();
        if (!$obj) {
            return [];
        }
        $args = func_get_args();
        switch (count($args)) {
            case 0:
                return $obj->getAccessListItems();
            case 1:
                return $obj->getAccessListItems($args[0]);
            case 2:
                return $obj->getAccessListItems($args[0], $args[1]);
            case 3:
                return $obj->getAccessListItems($args[0], $args[1], $args[2]);
            default:
                return call_user_func_array([$obj, 'getAccessListItems'], $args);
        }
    }
248059
private function getRequestedRoles()
    {
        $rules = $this->config->get('Rules', false);
        if (!$rules) {
            return [];
        }

        // see which of the rules matches the path and extract the requested roles for access
        $returnRoles = [];
        foreach ($rules as $r) {
            $path = $r->get('Path', false);
            if ($path && $this->testPath($path)) {
                $roles = $r->get('Roles', []);
                if ($this->isString($roles)) {
                    $roles = (array)$roles;
                } else {
                    $roles = $roles->toArray();
                }

                // covert the role names to Role instances
                foreach ($roles as $role) {
                    $returnRoles[] = new Role($role);
                }

                return $returnRoles;
            }
        }

        return [];
    }
898947
private function getAllMappedPermissions(): array
    {
        $mappedPermissions = [];
        foreach (Craft::$app->userPermissions->getAllPermissions() as $permissions) {
            $mappedPermissions = array_merge($mappedPermissions, $this->getMappedPermissions($permissions));
        }

        return $mappedPermissions;
    }
490875
public function getPermissionsAttribute()
    {
        $permissions = new Collection();

        foreach ($this->roles as $role) {
            foreach ($role->permissions as $permission) {
                $permissions->push($permission);
            }
        }

        return $permissions;
    }