Cartalyst\Sentinel\Sentinel::bypassCheckpoints PHP Method

bypassCheckpoints() public method

Pass a closure to Sentinel to bypass checkpoints.
public bypassCheckpoints ( Closure $callback, array $checkpoints = [] ) : mixed
$callback Closure
$checkpoints array
return mixed
    public function bypassCheckpoints(Closure $callback, $checkpoints = [])
    {
        $originalCheckpoints = $this->checkpoints;
        $activeCheckpoints = [];
        foreach (array_keys($originalCheckpoints) as $checkpoint) {
            if ($checkpoints && !in_array($checkpoint, $checkpoints)) {
                $activeCheckpoints[$checkpoint] = $originalCheckpoints[$checkpoint];
            }
        }
        // Temporarily replace the registered checkpoints
        $this->checkpoints = $activeCheckpoints;
        // Fire the callback
        $result = $callback($this);
        // Reset checkpoints
        $this->checkpoints = $originalCheckpoints;
        return $result;
    }

Usage Example

Example #1
0
 /**
  * Pass a closure to Sentinel to bypass checkpoints.
  *
  * @param  \Closure $callback
  * @param  array   $checkpoints
  *
  * @return mixed
  */
 public function bypassCheckpoints(\Closure $callback, $checkpoints = [])
 {
     return $this->sentinel->bypassCheckpoints($callback, $checkpoints);
 }
All Usage Examples Of Cartalyst\Sentinel\Sentinel::bypassCheckpoints