lithium\net\http\Media::scope()
Scope getter/setter.
Special use case: If $closure is not null executing the closure inside
the specified scope.
Parameters
-
string
$nameName of the scope to use.
-
\Closure
$closureA closure to execute inside the scope.
Returns
mixedReturns the previous scope if if $name is not null and $closure is null,
returns the default used scope if $name is null, otherwise returns null.
Source
public static function scope($name = null, Closure $closure = null) {
if ($name === null) {
return static::$_scope;
}
if ($closure === null) {
$former = static::$_scope;
static::$_scope = $name;
return $former;
}
$former = static::$_scope;
static::$_scope = $name;
call_user_func($closure);
static::$_scope = $former;
}