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

public static method

Sets or gets default/previous named scope.

Please note: scopes are not compatible with the "library" based route syntax. This mean you can't mix them, you need to choose either the old way (i.e the "library" based route syntax), or the the scope syntax to build your routes.

If you move completely to scopes, you don't need to deal with {:library} anymore, the scoping feature will do the job for you.

Parameters

  • string|null $name

    Name of the scope to use or null when you want to get the default scope.

  • \Closure $closure

    A closure to execute inside the scope.

Returns

mixed

If $name is null returns the default used scope, otherwise returns the previous named scope. Once $closure is used, 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;
	}