add permissions to role

@param array $permissions array of permission names
767386
public function addPermissions($permissions) {
		foreach ($permissions as $permission) {
			$per                                 = new permission($permission);
			$this->role->sharedPermissionList [] = $per->get();
		}
		R::store($this->role);
	}
654806
protected function _addRoles(array $roles) {
        foreach ($roles as $roleName => $properties) {
            // If the properties aren't set as an array, then we will consider
            // the value as the role ID.
            if (!is_array($properties)) {
                $properties = array('id' => $properties);
            }

            $id = $properties['id'];

            if (is_null($id) || empty($id)) {
                throw new Zend_Application_Resource_Exception(
                    sprintf(
                        $this->_missingPropertyMessage, 'ID', 'role', $roleName
                    )
                );
            }
            $this->_addRoleById($roles, $id);
        }
    }
863794
@Override
    public void addPermissions(IPermission[] permissions) throws AuthorizationException {
        if (permissions.length > 0) {
            getPermissionStore().add(permissions);
            if (this.cachePermissions) {
                removeFromPermissionsCache(permissions);
            }
        }
    }
972005
public function attachPermissions($permissions, $reload = true)
    {
        event(new AttachingPermissionsToGroup($this, $permissions));
        $permissions = $this->permissions()->saveMany($permissions);
        event(new AttachedPermissionsToGroup($this, $permissions));

        $this->loadPermissions($reload);

        return $permissions;
    }
540159
public function setPermissions(ResourceRights $rights, array $permissions)
    {
        $resourceType = $rights->getResourceNode()->getResourceType();
        $rights->setMask($this->maskManager->encodeMask($permissions, $resourceType));

        return $rights;
    }
952061
public function hookUserRolePermissions(array &$permissions)
    {
        $permissions['module_file_manager'] = gplcart_text('File manager: access');

        foreach ($this->getHandlers() as $command_id => $command) {
            $permissions["module_file_manager_$command_id"] = gplcart_text('File manager: perform command @name', array(
                '@name' => $command['name']));
        }
    }
989138
public function setPermissions($permissions)
    {
        if (! is_array($permissions)) {
            $permissions = [$permissions];
        }

        $this->permissions = $permissions;

        return $this;
    }
1165193
public function addCollection(PermissionCollection $permissions)
    {
        if ($permissions->getObjectType() !== $this->getObjectType()) {
            throw new InvalidArgumentException('Mismating object types.');
        }

        foreach ($permissions->all() as $permission) {
            $this->add($permission);
        }

        return $this;
    }
1194620
public static function CompilePermissions($Permissions) {
      $Compiled = array();
      foreach ($Permissions as $i => $Row) {
         $JunctionID = array_key_exists('JunctionID', $Row) ? $Row['JunctionID'] : null;
         //$JunctionTable = array_key_exists('JunctionColumn', $Row) ? $Row['JunctionTable'] : null;
         //$JunctionColumn = array_key_exists('JunctionColumn', $Row) ? $Row['JunctionColumn'] : null;
         unset($Row['JunctionColumn'], $Row['JunctionColumn'], $Row['JunctionID'], $Row['RoleID'], $Row['PermissionID']);
         
         foreach ($Row as $PermissionName => $Value) {
            if ($Value == 0)
               continue;
            
            if (is_numeric($JunctionID) && $JunctionID !== NULL) {
               if (!array_key_exists($PermissionName, $Compiled))
                  $Compiled[$PermissionName] = array();
                  
               if (!is_array($Compiled[$PermissionName]))
                  $Compiled[$PermissionName] = array();
                  
               $Compiled[$PermissionName][] = $JunctionID;
            } else {
               $Compiled[] = $PermissionName;
            }
         }
      }
      
      return $Compiled;
   }
110786
protected function addRoles($roles)
    {
        if (!is_array($roles) && !($roles instanceof \Traversable)) {
            $roles = array($roles);
        }

        /* @var $role Role */
        foreach ($roles as $role) {
            if ($this->acl->hasRole($role)) {
                continue;
            }

            if ($role->getParent() !== null) {
                $this->addRoles(array($role->getParent()));
                $this->acl->addRole($role, $role->getParent());
            } elseif (!$this->acl->hasRole($role)) {
                $this->acl->addRole($role);
            }
        }
    }
1223042
public static function register(array $permissions): void
    {
        $permissions = self::format($permissions);

        self::$permissions = array_merge(self::$permissions, $permissions);
    }
616727
public function addPermission($permission) {
		$per                                 = new permission($permission);
		$this->role->sharedPermissionList [] = $per->get();
		R::store($this->role);
	}
85952
public function setRoles($roles)
    {
        if (!is_array($roles)) {
            $roles = [$roles];
        }

        $this->roles = $roles;

        return $this;
    }
318705
public function setPermissionsAttribute(array $permissions = [])
    {
        foreach ($permissions as $key => $value) {
            $permissions[$key] = (bool) $value;
        }
        $this->attributes['permissions'] = json_encode($permissions ?? []);
    }
205364
public function eachPermission(array $permissions, callable $callback)
    {
        $permissions = array_flatten($permissions);

        foreach ($permissions as $permission) {
            if ($permission = $this->preparePermission($permission)) {
                $callback($permission);    
            }
        }
    }
215045
public function syncPermissions($permissions)
    {
        $mappedPermissions = [];

        foreach ($permissions as $permission) {
            $mappedPermissions[] = Helper::getIdFor($permission, 'permission');
        }

        $changes = $this->permissions()->sync($mappedPermissions);
        $this->flushCache();
        $this->fireLaratrustEvent("permission.synced", [$this, $changes]);

        return $this;
    }
243334
protected function userHasPermission(array $permissions)
    {
        if ( ! count($permissions)) {
            return true;
        }

        return (bool) count(
            array_filter($permissions, function ($permission) {
                return array_get($this->userPermissions, $permission);
            })
        );
    }