lithium\net\http\Media::webroot PHP Méthode

webroot() public static méthode

Gets the physical path to the web assets (i.e. /webroot) directory of a library.
public static webroot ( string | boolean $library = true, string | boolean $scope = null ) : string
$library string | boolean The name of the library for which to find the path, or `true` for the default library.
$scope string | boolean The name of the to use to find the path.
Résultat string Returns the physical path to the web assets directory.
    public static function webroot($library = true, $scope = null)
    {
        if ($scope) {
            if ($config = static::attached($scope)) {
                return $config['path'];
            }
            return null;
        }
        if (!($config = Libraries::get($library))) {
            return null;
        }
        if (isset($config['webroot'])) {
            return $config['webroot'];
        }
        if (isset($config['path'])) {
            return $config['path'] . '/webroot';
        }
    }

Usage Example

Exemple #1
0
 public function testGetLibraryWebroot()
 {
     $this->assertTrue(is_dir(Media::webroot(true)));
     $this->assertNull(Media::webroot('foobar'));
     Libraries::add('foobar', array('path' => __DIR__, 'webroot' => __DIR__));
     $this->assertEqual(__DIR__, Media::webroot('foobar'));
     Libraries::remove('foobar');
 }
All Usage Examples Of lithium\net\http\Media::webroot