Nwidart\Modules\Repository::asset PHP Méthode

asset() public méthode

Get asset url from a specific module.
public asset ( string $asset ) : string
$asset string
Résultat string
    public function asset($asset)
    {
        list($name, $url) = explode(':', $asset);
        $baseUrl = str_replace(public_path() . DIRECTORY_SEPARATOR, '', $this->getAssetsPath());
        $url = $this->app['url']->asset($baseUrl . "/{$name}/" . $url);
        return str_replace(['http://', 'https://'], '//', $url);
    }

Usage Example

 /** @test */
 public function it_gets_a_specific_module_asset()
 {
     $path = $this->repository->asset('recipe:test.js');
     $this->assertEquals('//localhost/modules/recipe/test.js', $path);
 }