Return all the AROs with their permissions mapped.

@return array
979320
protected function getRequesters() {
        $mapParentId = array();
        $mapAroId = array();

        $aros = $this->Aro->getAll();
        $permissions = $this->Permission->getAll();

        // Map ACOs to AROs indexed by IDs
        foreach ($permissions as $permission) {
            $permission = $permission['ObjectPermission'];

            $mapAroId[$permission['aro_id']][$permission['aco_id']] = $permission;
        }

        // Map IDs to parent IDs
        foreach ($aros as $aro) {
            $mapParentId[$aro['RequestObject']['id']] = $aro['RequestObject'];
        }

        // Loop through AROs and determine permissions
        // While taking into account inheritance
        foreach ($aros as &$aro) {
            $id = $aro['RequestObject']['id'];
            $parent_id = $aro['RequestObject']['parent_id'];
            $inheritance = array();

            while (isset($mapParentId[$parent_id])) {
                array_unshift($inheritance, $parent_id);
                $parent_id = $mapParentId[$parent_id]['parent_id'];
            }

            $inheritance[] = $id;

            // Fetch permissions from parents
            $perms = array();
            $parent_id = $aro['RequestObject']['parent_id']; // reset $parent_id

            foreach ($inheritance as $pid) {
                if (isset($mapAroId[$pid])) {
                    $perms = Hash::merge($perms, array_map(function($value) use ($id, $parent_id) {

                        // If the ARO on the permission doesn't match the current ARO
                        // It is being inherited, so force it to 0
                        if ($id != $value['aro_id']) {
                            $value = array_merge($value, array(
                                '_create' => 0,
                                '_read' => 0,
                                '_update' => 0,
                                '_delete' => 0
                            ));

                        // Top level AROs cant inherit from nothing
                        // So change those values to denied
                        } else if (empty($parent_id)) {
                            foreach (array('_create', '_read', '_update', '_delete') as $action) {
                                if ($value[$action] == 0) {
                                    $value[$action] = -1;
                                }
                            }
                        }

                        return $value;
                    }, $mapAroId[$pid]));
                }
            }

            $aro['ObjectPermission'] = $perms;
        }

        return $aros;
    }
338233
public function rolesPermissions() {
    return [
      self::ROLE_USER => [
      ],
      self::ROLE_USER_MANAGER => [
        self::USER_VIEW,
        self::USER_CREATE,
        self::USER_UPDATE,
        self::USER_CHANGE_SECURITY_INFO,
        self::USER_CHANGE_PROFILE_INFO,
      ],
      self::ROLE_ADMIN => [
      ],
    ];
  }
1119790
public function getPermissions()
    {
        if(!$this->permissions){
            $rolePermissions = $this->rolePermissions();
            $userPermissions = $this->grantedPermissions()->get();

            $permissions = $rolePermissions->merge($userPermissions);
            $deniedPermissions =$this->deniedPermissions()->get();

            $this->permissions = $permissions->filter(function($permission) use ($deniedPermissions)
            {
                return !$deniedPermissions->contains($permission);
            });
        }
        return $this->permissions;
    }
490875
public function getPermissionsAttribute()
    {
        $permissions = new Collection();

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

        return $permissions;
    }
1256051
public static function permissions(): array
    {
        $aPermissions = parent::permissions();

        //  Fetch the blogs, each blog should have its own admin nav grouping
        $oCi =& get_instance();
        $oCi->load->model('blog/blog_model');
        $aBlogs = $oCi->blog_model->getAll();

        $aOut = array();

        if (!empty($aBlogs)) {

            foreach ($aBlogs as $oBlog) {

                $aPermissions[$oBlog->id . ':manage']  = $oBlog->label . ': Can manage posts';
                $aPermissions[$oBlog->id . ':create']  = $oBlog->label . ': Can create posts';
                $aPermissions[$oBlog->id . ':edit']    = $oBlog->label . ': Can edit posts';
                $aPermissions[$oBlog->id . ':delete']  = $oBlog->label . ': Can delete posts';
                $aPermissions[$oBlog->id . ':restore'] = $oBlog->label . ': Can restore posts';

            }
        }

        return $aPermissions;
    }
798993
protected function _getKeys() {
        $keys = $this->Permissions->schema()->columns();
        $newKeys = array();
        foreach ($keys as $key) {
            if (!in_array($key, array('id', 'aro_id', 'aco_id'))) {
                $newKeys[] = $key;
            }
        }
        return $newKeys;
    }
448474
public function getRolesWithPermissions()
    {
        $roles = Roles::with('permissions')
            ->notSuperAdmin()
            ->orderBy('name')
            ->get()->map(function ($role) {
                return [
                    'id'          => $role->id,
                    'role'        => $role->name,
                    'slug'        => $role->slug,
                    'permissions' => $role->permissions->pluck('id')->all(),
                ];
            });

        return json_encode($roles);
    }
460133
public static function permissions(): array
    {
        $aPermissions = parent::permissions();

        $aPermissions['object:browse']  = 'Can browse existing objects';
        $aPermissions['object:create']  = 'Can create new objects';
        $aPermissions['object:delete']  = 'Can delete existing objects';
        $aPermissions['object:restore'] = 'Can restore deleted objects';
        $aPermissions['object:purge']   = 'Can purge deleted objects';
        $aPermissions['bucket:create']  = 'Can create new buckets';

        return $aPermissions;
    }
1169512
public function permissionsToRegister()
    {
        $config = config('acl');
        $permissionPlaceholders = array_get($config, 'permission_placeholders');
        $additionalPermissions = array_get($config, 'additional');
        $permissionsToRegister = [];

        $routes = array_filter($this->router->getRoutes()->getRoutes(), function ($route) {
            return $route->getName() and ! in_array($route->getName(), AclPolicy::getExcept());
        });

        foreach ($routes as $route) {
            if (array_key_exists($route->getName(), $permissionPlaceholders)) {
                $permissionsToRegister[$route->getName()] = $permissionPlaceholders[$route->getName()];
            } else {
                $permissionsToRegister[$route->getName()] = $route->getName();
            }
        }

        return array_merge($permissionsToRegister, $additionalPermissions);
    }
520930
public function GetAllowedPermissionNamespaces() {
      $ApplicationManager = new Gdn_ApplicationManager();
      $EnabledApplications = $ApplicationManager->EnabledApplications();
      
      $PluginNamespaces = array();
      foreach(Gdn::PluginManager()->EnabledPlugins() as $Plugin) {
         if(!array_key_exists('RegisterPermissions', $Plugin) || !is_array($Plugin['RegisterPermissions']))
            continue;
         foreach($Plugin['RegisterPermissions'] as $Index => $PermissionName) {
            if (is_string($Index))
               $PermissionName = $Index;
            
            $Namespace = substr($PermissionName, 0, strrpos($PermissionName, '.'));
            $PluginNamespaces[$Namespace] = TRUE;
         }
      }
      
      $Result = array_merge(array_keys($EnabledApplications), array_keys($PluginNamespaces));
		if(in_array('Dashboard', $Result))
			$Result[] = 'Garden';
		return $Result;
   }
721639
public static function map()
    {
        $permissions = [];

        foreach (static::get() as $permission) {
            $permissions[$permission->permission][] = (string) $permission->group_id;
        }

        return $permissions;
    }
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;
    }
304323
public function getPermissions()
    {
        $registry = $this->getService('application.registry');
        $key = $this->getIdentifier().'-permissions';

        if (!$registry->offsetExists($key)) {
            $registry->offsetSet($key, self::_getDefaultPermissions($this));
        }

        return $registry->offsetGet($key);
    }
954512
protected function getFreshRolesPermissions()
    {
        $roles = $this->roles()->get(['id'])->pluck('id')->toArray();

        return app('defender.permission')->getByRoles($roles);
    }
454913
public function getPermissions()
    {
        $mode     = \RecursiveIteratorIterator::CHILD_FIRST;
        $iterator = $this->createRecursiveIterator($mode);

        $permissions = [];

        /** @var $child RoleInterface */
        foreach ($iterator as $child) {
            $permissions = array_replace_recursive($permissions, $child->getPermissions());
        }

        return array_replace_recursive($permissions, $this->permissions);
    }
854623
public function getPermissionsInherited()
    {
        $rights = [];
        $permissions = $this->permissions;

        // ntfs permissions
        // determine if ntfs is enabled
        // then more permissive wins
        $tmp = [];
        $letNtfs = function ($alias, $slug) use (&$tmp) {
            if ( config('acl.most_permissive_wins', false) ) {
                $ntfs[$alias] = array_diff($slug, [false]);
                if ( sizeof($ntfs) > 0 ) {
                    $tmp = array_replace_recursive($tmp, $ntfs);
                }
            }
        };

        foreach ($permissions as $row) {

            // permissions without inherit ids
            if ( is_null($row->inherit_id) || ! $row->inherit_id ) {

                // ntfs determination
                $letNtfs($row->name, $row->slug);

                // merge permissions
                $rights = array_replace_recursive($rights, [$row->name => $row->slug], $tmp);
                continue;
            }

            // process inherit_id recursively
            $inherited = $this->getRecursiveInherit($row->inherit_id, $row->slug);
            $merge = $permissions->where('name', $row->name);
            $merge = method_exists($merge, 'pluck') ? $merge->pluck('slug', 'name') : $merge->lists('slug', 'name');

                // fix for l5.1 and backward compatibility.
            // lists() method should return as an array.
            $merge = $this->collectionAsArray($merge);

            // replace and merge permissions
            $rights = array_replace_recursive($rights, $inherited, $merge);

            // make sure we don't unset if
            // inherited & slave permission
            // have same names
            if ( key($inherited) != $row->name )
                unset($rights[$row->name]);

        }

        return $rights;
    }
718657
public static function all()
    {
        $preference = collect(['laralum', 'dashboard', 'users', 'roles', 'permissions']);

        collect(static::get())->each(function ($package) use ($preference) {
            if (!$preference->contains($package)) {
                $preference->push($package);
            }
        });

        return $preference->toArray();
    }