lithium\net\http\Media::scope()

public static method

Scope getter/setter.

Special use case: If $closure is not null executing the closure inside the specified scope.

Parameters

  • string $name

    Name of the scope to use.

  • \Closure $closure

    A closure to execute inside the scope.

Returns

mixed

Returns 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;
	}