public static scope ( string $name = null, Closur\Closure $closure = null ) : mixed | ||
$name | string | Name of the scope to use. |
$closure | Closur\Closure | A closure to execute inside the scope. |
return | 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`. |
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;
}
public function testEmptyHostAndSchemeOptionLocation() { Media::attach('app', array('absolute' => true)); Media::scope('app'); $result = Media::asset('/js/path/file', 'js', array('base' => '/app/base')); $expected = 'http://localhost/app/base/js/path/file.js'; $this->assertEqual($expected, $result); }