Get asset url from a specific module.

@param string $asset
@param bool   $secure

@return string
765323
public function asset($asset)
    {
        list($name, $url) = explode(':', $asset);

        $baseUrl = str_replace(public_path(), '', $this->getAssetsPath());

        $url = $this->app['url']->asset($baseUrl."/{$name}/".$url);

        return str_replace(['http://', 'https://'], '//', $url);
    }
879539
public function urlIf($condition, string $path, string $text, array $parameters = [], $secure = null)
    {
        return $this->addIf($condition, Link::toUrl($path, $text, $parameters, $secure));
    }
1322860
public function moduleAsset($asset, $module = null, $absolute = false)
    {
        return $this->createAssetPath($asset, $module, $absolute, true);
    }
715305
public static function hash($data, bool $secure = false): string
    {
        return hash(self::getAlgo($secure), (string) $data);
    }
810256
public function getAsset($asset, $extensionId = null)
    {
        if( ! is_null($extensionId)){
            $url = $this->getJsBaseWww($extensionId) . FsUtils::normalizePath($asset);
        } else {
            $url = $this->getAssetBaseUrl() . FsUtils::normalizePath($asset);
        }

        $isFolder = (substr_compare($url, '/', strlen($url) - 1) === 0);

        $buster = $this->getCacheBuster();
        if($buster != false && $isFolder == false) {
            $url .= '?' . self::BUSTER_QUERY_KEY . '=' . urlencode($buster);
        }

        return $url;
    }
624123
public function formatScheme($secure)
    {
        if (! is_null($secure)) {
            return $secure ? 'https://' : 'http://';
        }

        if (is_null($this->cachedSchema)) {
            $this->cachedSchema = $this->forceScheme ?: $this->request->getScheme().'://';
        }

        return $this->cachedSchema;
    }
415639
public function get_url($forcedownload=false, $https=false) {
        if (!$this->is_readable()) {
            return null;
        }

        if ($this->is_directory()) {
            return null;
        }

        $this->urlbase;
        $contextid = $this->lf->get_contextid();
        $component = $this->lf->get_component();
        $filearea  = $this->lf->get_filearea();
        $itemid    = $this->lf->get_itemid();
        $filepath  = $this->lf->get_filepath();
        $filename  = $this->lf->get_filename();

        if ($this->itemidused) {
            $path = '/'.$contextid.'/'.$component.'/'.$filearea.'/'.$itemid.$filepath.$filename;
        } else {
            $path = '/'.$contextid.'/'.$component.'/'.$filearea.$filepath.$filename;
        }
        return file_encode_url($this->urlbase, $path, $forcedownload, $https);
    }
859843
protected function locateResource($asset = null)
    {
        if (null === $asset) {
            $asset = $this->asset;
        }

        $asset = $this->normalizePath($asset);
        if(\substr($asset, 0, 1) != '@') $asset = '@' . $asset;

        try
        {
            // Fetches the relative resource to locate from asset
            preg_match('/(@[^\/]+)?([\w\/\.\-_]+)?/', $asset, $match);
            if (empty($match[1])) {
                return;
            }

            $resource = $this->kernel->locateResource($match[1]);
            
            $resourceLength = strlen($resource) - 1;
            if (substr($resource, $resourceLength, 1) == '/') $resource = substr($resource, 0, $resourceLength);

            return (isset($match[2])) ? $resource . $match[2] : $resource;
        }
        catch(\Exception $e)
        {
            return null;
        }
    }
1094738
public function loadFile (Asset $asset, ?bool $mode) : string
    {
        $filePath = $this->getFilePath($asset);

        if (!\is_file($filePath))
        {
            throw new FileNotFoundException(sprintf(
                "Asset '%s' not found at '%s'.",
                $asset->getAssetPath(),
                $filePath
            ));
        }

        $fileContent = \file_get_contents($filePath);

        if (false === $fileContent)
        {
            throw new FileNotFoundException(sprintf(
                "Can't read asset file '%s' at '%s'.",
                $asset->getAssetPath(),
                $filePath
            ));
        }

        $fileType = $this->fileTypeRegistry->getFileType($asset);

        if (self::MODE_UNTOUCHED !== $mode)
        {
            // prepend file header in dev and process in prod
            $fileContent = (self::MODE_PROD === $mode)
                ? $fileType->processForProd($asset, $fileContent)
                : $fileType->processForDev($asset, $filePath, $fileContent);
        }

        return $fileContent;
    }
1002100
public function findThemeAsset($theme, $asset)
    {
        if (! empty($theme)) {
            $Folders = $this->engine->getFolders();

            if ($Folders->exists($theme)) {
                $this->Folder = $Folders->get($theme);
                $folderPath = rtrim($this->Folder->getPath(), '/');

                $folderPath = $this->removeViewFromPath($folderPath);

                if (file_exists($folderPath . DS . $asset)) {
                    $this->createSymlink($folderPath);

                    return '/' . $this->assetDir . '/' . $this->asset['asset'];
                }
            }
        }
        return false;
    }
796595
public function formatScheme($secure = null)
    {
        if (! is_null($secure)) {
            return $secure ? 'https://' : 'http://';
        }

        if (is_null($this->cachedScheme)) {
            $this->cachedScheme = $this->forceScheme ?: $this->request->getScheme().'://';
        }

        return $this->cachedScheme;
    }
1240305
public function asset($asset, $module = null, $absolute = false)
    {
        return $this->createAssetPath($asset, $module, $absolute, false);
    }
703387
public function img($asset, $extension = null)
	{
		$extension = $extension ?: $this->detectExtensionName();

		$asset = new Image($extension, $asset);

		return $asset->link();
	}
1352008
public static function getRandomHash(bool $secure = false): string
    {
        return self::hash(microtime() . rand(10000, 100000), $secure);
    }
537157
public function formatScheme($secure)
    {
        if (! \is_null($secure)) {
            return $secure ? 'https://' : 'http://';
        }

        if (\is_null($this->cachedSchema)) {
            $this->cachedSchema = $this->forceScheme ?: $this->app->make('request')->getScheme().'://';
        }

        return $this->cachedSchema;
    }
1169272
public static function root($secure = null)
    {
        $framework = '/public/index.php';
        $server = request('PHP_SELF', '', 'server');
        $scheme = (is_null($secure) ? request('REQUEST_SCHEME', '', 'server') : ($secure ? 'https' : 'http')).'://';
        $serverName = request('SERVER_NAME', '', 'server');

        $parts = explode($framework, $server);

        $root = $parts[0].'/';

        return $scheme.$serverName.$root;
    }
673032
public function fromAsset(Asset $asset)
	{
		Craft::$app->getDeprecator()->log('craft.embeddedAssets.fromAsset', "The template method `craft.embeddedAssets.fromAsset` is now deprecated. Use `craft.embeddedAssets.get` instead.");

		return EmbeddedAssets::$plugin->methods->getEmbeddedAsset($asset);
	}