src/Permissions/ACL.php
private function fill($roles, $resources, $allow) {

		if(true === is_string($roles)) {
			$roles = [$roles];
		}

		if(true === is_string($resources)) {
			$resources = [$resources];
		}

		if(false === is_array($roles)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string or array, "%s" given', __METHOD__, gettype($roles)), E_USER_ERROR);
		}

		if(false === is_array($resources)) {
			return trigger_error(sprintf('Argument 2 passed to %s() must be of the type string or array, "%s" given', __METHOD__, gettype($resources)), E_USER_ERROR);
		}

		if(false === is_bool($allow)) {
			return trigger_error(sprintf('Argument 3 passed to %s() must be of the type boolean, "%s" given', __METHOD__, gettype($allow)), E_USER_ERROR);
		}

		foreach($roles as $role) {

			if(false === is_string($role)) {
				return trigger_error(sprintf('Argument 1 passed to %s() must contain only strings, "%s" given', __METHOD__, gettype($role)), E_USER_ERROR);
			}

			if(false === isset($this -> permissions[$role])) {
				$this -> permissions[$role] = [];
			}

			foreach($resources as $resource) {

				if(false === is_string($resource)) {
					return trigger_error(sprintf('Argument 2 passed to %s() must contain only strings, "%s" given', __METHOD__, gettype($resource)), E_USER_ERROR);
				}

				$this -> permissions[$role][$resource] = $allow;
			}
		}

		return $this;
	}
private function fill($roles, $resources, $allow) {

		if(true === is_string($roles)) {
			$roles = [$roles];
		}

		if(true === is_string($resources)) {
			$resources = [$resources];
		}

		if(false === is_array($roles)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string or array, "%s" given', __METHOD__, gettype($roles)), E_USER_ERROR);
		}

		if(false === is_array($resources)) {
			return trigger_error(sprintf('Argument 2 passed to %s() must be of the type string or array, "%s" given', __METHOD__, gettype($resources)), E_USER_ERROR);
		}

		if(false === is_bool($allow)) {
			return trigger_error(sprintf('Argument 3 passed to %s() must be of the type boolean, "%s" given', __METHOD__, gettype($allow)), E_USER_ERROR);
		}

		foreach($roles as $role) {

			if(false === is_string($role)) {
				return trigger_error(sprintf('Argument 1 passed to %s() must contain only strings, "%s" given', __METHOD__, gettype($role)), E_USER_ERROR);
			}

			if(false === isset($this -> permissions[$role])) {
				$this -> permissions[$role] = [];
			}

			foreach($resources as $resource) {

				if(false === is_string($resource)) {
					return trigger_error(sprintf('Argument 2 passed to %s() must contain only strings, "%s" given', __METHOD__, gettype($resource)), E_USER_ERROR);
				}

				$this -> permissions[$role][$resource] = $allow;
			}
		}

		return $this;
	}
private function fill ( $ roles , $ resources , $ allow ) { if ( true === is_string ( $ roles ) ) { $ roles = [ $ roles ] ; } if ( true === is_string ( $ resources ) ) { $ resources = [ $ resources ] ; } if ( false === is_array ( $ roles ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string or array, "%s" given' , __METHOD__ , gettype ( $ roles ) ) , E_USER_ERROR ) ; } if ( false === is_array ( $ resources ) ) { return trigger_error ( sprintf ( 'Argument 2 passed to %s() must be of the type string or array, "%s" given' , __METHOD__ , gettype ( $ resources ) ) , E_USER_ERROR ) ; } if ( false === is_bool ( $ allow ) ) { return trigger_error ( sprintf ( 'Argument 3 passed to %s() must be of the type boolean, "%s" given' , __METHOD__ , gettype ( $ allow ) ) , E_USER_ERROR ) ; } foreach ( $ roles as $ role ) { if ( false === is_string ( $ role ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must contain only strings, "%s" given' , __METHOD__ , gettype ( $ role ) ) , E_USER_ERROR ) ; } if ( false === isset ( $ this -> permissions [ $ role ] ) ) { $ this -> permissions [ $ role ] = [ ] ; } foreach ( $ resources as $ resource ) { if ( false === is_string ( $ resource ) ) { return trigger_error ( sprintf ( 'Argument 2 passed to %s() must contain only strings, "%s" given' , __METHOD__ , gettype ( $ resource ) ) , E_USER_ERROR ) ; } $ this -> permissions [ $ role ] [ $ resource ] = $ allow ; } } return $ this ; }
Add a new permission entry
@param string|array $roles
@param string|array $resources
@param boolean $allow
@return sFire\Permissions\ACL
Add a new permission entry