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

public static method

Attach a scope to a mount point.

Example:

Media::attach('app', [
    'path' => '/var/www/website/webroot/extradir',
    'prefix' => 'extradir'
]);
Media::attach('cdn', [
    'absolute' => true,
    'path' => null,
    'host' => 'http://my.cdn.com',
    'prefix' => 'project1/assets'
]);
Media::attach('cdn', [
    'absolute' => true,
    'path' => null,
    'host' => ['my.cdn.com', 'secure.cdn.com'],
    'scheme' => ['http://', 'https://'],
    'prefix' => 'project1/assets',
]);
Media::attach('cdn', [
    'absolute' => true,
    'path' => null,
    'host' => ['my1.cdn.com', 'my2.cdn.com'],
    'scheme' => 'http://',
    'prefix' => 'project1/assets',
]);

Parameters

  • string $name

    The name of the media you wish to attach.

  • array

    $config Asset configuration options for the given scope.

    • 'path' string: Path of the media.
    • 'prefix' string: Contains the uri prefix. Such as css.
    • 'absolute' boolean: Defaults to false. If you want to generate absolute URL's.
    • 'host' mixed: String host, or array of hosts, of the media, if absolute is true.
    • 'scheme' mixed: String scheme, or array of sc, of the media, if absolute is true.

Returns

void

Source

	public static function attach($name, $config = null) {
		if (!isset(static::$_scopes)) {
			static::_initScopes();
		}
		if ($name === false) {
			$name = '__defaultScope__';
		}
		if (is_array($config) || $config === false) {
			static::$_scopes->set($name, $config);
		}
	}