src/Lock.php
public function allow($action, $resource = null, $resourceId = null, $conditions = [])
    {
        $actions = (array) $action;
        $resource = $this->convertResourceToObject($resource, $resourceId);
        $permissions = $this->getPermissions();

        foreach ($actions as $action) {
            foreach ($permissions as $key => $permission) {
                if ($permission instanceof Restriction && ! $permission->isAllowed($this, $action, $resource)) {
                    $this->removePermission($permission);
                    unset($permissions[$key]);
                }
            }

            // We'll need to clear any restrictions above
            $restriction = new Restriction($action, $resource);

            if ($this->hasPermission($restriction)) {
                $this->removePermission($restriction);
            }

            $this->storePermission(new Privilege($action, $resource, $conditions));
        }
    }
public function allow($action, $resource = null, $resourceId = null, $conditions = [])
    {
        $actions = (array) $action;
        $resource = $this->convertResourceToObject($resource, $resourceId);
        $permissions = $this->getPermissions();

        foreach ($actions as $action) {
            foreach ($permissions as $key => $permission) {
                if ($permission instanceof Restriction && ! $permission->isAllowed($this, $action, $resource)) {
                    $this->removePermission($permission);
                    unset($permissions[$key]);
                }
            }

            // We'll need to clear any restrictions above
            $restriction = new Restriction($action, $resource);

            if ($this->hasPermission($restriction)) {
                $this->removePermission($restriction);
            }

            $this->storePermission(new Privilege($action, $resource, $conditions));
        }
    }
public function allow ( $ action , $ resource = null , $ resourceId = null , $ conditions = [ ] ) { $ actions = ( array ) $ action ; $ resource = $ this -> convertResourceToObject ( $ resource , $ resourceId ) ; $ permissions = $ this -> getPermissions ( ) ; foreach ( $ actions as $ action ) { foreach ( $ permissions as $ key => $ permission ) { if ( $ permission instanceof Restriction && ! $ permission -> isAllowed ( $ this , $ action , $ resource ) ) { $ this -> removePermission ( $ permission ) ; unset ( $ permissions [ $ key ] ) ; } } // We'll need to clear any restrictions above $ restriction = new Restriction ( $ action , $ resource ) ; if ( $ this -> hasPermission ( $ restriction ) ) { $ this -> removePermission ( $ restriction ) ; } $ this -> storePermission ( new Privilege ( $ action , $ resource , $ conditions ) ) ; } }
Give the subject permission to do something

@param string|array $action
@param string|\BeatSwitch\Lock\Resources\Resource $resource
@param int $resourceId
@param \BeatSwitch\Lock\Permissions\Condition|\BeatSwitch\Lock\Permissions\Condition[]|\Closure $conditions
Give the subject permission to do something