Combines asset file references of a single type to produce
a URL reference to the combined contents.
@param array $assets List of asset files.
@param string $localPath File extension, used for aesthetic purposes only.
@return string URL to contents.
340984
protected function prepareRequest(array $assets, $localPath = null)
    {
        if (substr($localPath, -1) != '/') {
            $localPath = $localPath.'/';
        }

        $this->localPath = $localPath;
        $this->storagePath = storage_path('cms/combiner/assets');

        list($assets, $extension) = $this->prepareAssets($assets);

        /*
         * Cache and process
         */
        $cacheKey = $this->getCacheKey($assets);
        $cacheInfo = $this->useCache ? $this->getCache($cacheKey) : false;

        if (!$cacheInfo) {
            $this->setHashOnCombinerFilters($cacheKey);

            $combiner = $this->prepareCombiner($assets);

            if ($this->useDeepHashing) {
                $factory = new AssetFactory($this->localPath);
                $lastMod = $factory->getLastModified($combiner);
            }
            else {
                $lastMod = $combiner->getLastModified();
            }

            $cacheInfo = [
                'version'   => $cacheKey.'-'.$lastMod,
                'etag'      => $cacheKey,
                'lastMod'   => $lastMod,
                'files'     => $assets,
                'path'      => $this->localPath,
                'extension' => $extension
            ];

            $this->putCache($cacheKey, $cacheInfo);
        }

        return $this->getCombinedUrl($cacheInfo['version']);
    }
1006151
public String asset(String path) {
        Asset asset = assets.assetAt(path);
        if (asset == null) {
            // If the path starts with "/", try without
            if (path.startsWith("/")) {
                return asset(path.substring(1));
            }
            // Not found.
            throw new TemplateProcessingException("Cannot find the URL of the asset " + path);
        }
        return asset.getPath();
    }
1247472
private function getAssetUrl($path)
    {
        $url = $this->assetsPackages->getUrl($path);
        if (!$url) {
            return $path;
        }

        /**
         * If `framework.assets.version: some_version` set, then $version = '?some_version'.
         * If `framework.assets: json_manifest_path` is used, then $version = '/'.
         */
        $version = $this->assetsPackages->getVersion($path);
        if (false === strpos($version, '?')) {
            return $url;
        }

        return preg_replace('/\?' . $version . '/', '', $url);
    }
1336090
private function rewritePathInStaticImport (Asset $asset, string $path) : string
    {
        // pass all URLs untouched, either "//..." or "schema:", where schema is a typical schema, that includes
        // http: https: and data:
        if (1 === \preg_match('~^(//|[a-z]+:)~', $path))
        {
            return $path;
        }

        $assetAtPath = $asset->getRelativeAsset($path);
        $assetAtPath = $this->cache->get($assetAtPath);

        if (null !== $assetAtPath)
        {
            // only overwrite the file name of the import
            $baseName = \basename($assetAtPath->getDumpFilePath());
            return \preg_replace('~(?<=^|/)[^/]*?$~', $baseName, $path);
        }

        return $path;
    }
17754
public static function getAssetUrl(string $path = '') : string
    {
        if (static::$assetUrl === null) {
            static::$assetUrl = FileHelper::getAssetUrl(static::className());
        }
        ;
        return static::$assetUrl . $path;
    }
670426
public function assetPath($path = null)
    {
        return ! is_null($path) ? $this->assetDir().'/'.ltrim($path, '/') : $this->assetDir();
    }
949276
public function get(string $path): SplFileInfo
    {
        $path = ltrim($path, '\\/');
        foreach ($this->assets as $asset) {
            if ($asset->getRelativePathname() === $path) {
                return $asset;
            }
        }
        throw new NotFoundHttpException(sprintf('Unknown asset: %s', $path));
    }
662717
public function getLocalFileListForPath($localPath)
    {
        $files = [];
        $objects = new RecursiveIteratorIterator(
            new RecursiveDirectoryIterator($localPath),
            RecursiveIteratorIterator::LEAVES_ONLY,
            FilesystemIterator::SKIP_DOTS
        );

        /**
         * @var string $path
         * @var SplFileObject $object
         */
        foreach ($objects as $path => $object) {
            /** @noinspection TypeUnsafeComparisonInspection */
            /** @noinspection NotOptimalIfConditionsInspection */
            if ($object->getFilename() != '.' && $object->getFilename() != '..') {
                $hostTempFolderPath = $this->_config->getHostSpoolerFolderPath();

                /** @noinspection PhpMethodOrClassCallIsNotCaseSensitiveInspection */
                $remoteFilePath = str_replace($hostTempFolderPath, '/', $object->getPathName());


                /** @noinspection PhpMethodOrClassCallIsNotCaseSensitiveInspection */
                $file = [
                    'name' => $object->getFilename(),
                    'localPath' => $object->getPathName(),
                    'remotePath' => $remoteFilePath,
                    'modified' => $object->getMTime()
                ];

                $files[$object->getFilename()] = $file;
            }
        }

        return $files;
    }
284893
protected function checkOptionalPath($assetPath)
    {
        if (0 === strpos($assetPath, '?')) {
            $assetPath = ltrim($assetPath, '?');
            $this->setOptional(true);
        }

        return $assetPath;
    }
228227
private function resolveLocalPath($partialPath)
    {
        $partialDir = str_replace('./', '', dirname($partialPath));
        $partialsDir = realpath(sprintf('%s%s',
                $this->_viewsDir,
                $partialDir
            )) . DIRECTORY_SEPARATOR;

        return $partialsDir . basename($partialPath);
    }
46489
public function deleteLocalFiles($localPath)
    {
        $it = new RecursiveDirectoryIterator(
            $localPath,
            RecursiveDirectoryIterator::SKIP_DOTS
        );

        $files = new RecursiveIteratorIterator(
            $it,
            RecursiveIteratorIterator::CHILD_FIRST
        );

        foreach ($files as $file) {
            if ($file->isDir()) {
                rmdir($file->getRealPath());
            } else {
                unlink($file->getRealPath());
            }
        }

        rmdir($localPath);
    }
604288
function (logicalPath) {
        var assets = self.getAssetsForLogicalPath(logicalPath);
        return assets.map(function (asset) {
          return '<script src="' + self.prefix + '/' + asset + '"></script>';
        }).join('\n');
      }
649695
public function buildRelativePath($path)
    {
        if (is_null($path)) return $path;

        $relativePath = str_replace(array(realpath($this->publicPath), '\\'), array('', '/'), $path);

        // If the asset is not a remote asset then we'll trim the relative path even further to remove
        // any unnecessary leading or trailing slashes. This will leave us with a nice relative path.
        if ( ! starts_with($path, '//') and ! (bool) filter_var($path, FILTER_VALIDATE_URL))
        {
            $relativePath = trim($relativePath, '/');

            // If the given path is the same as the built relative path then the asset appears to be
            // outside of the public directory. If this is the case then we'll use an MD5 hash of
            // the assets path as the relative path to the asset.
            if (trim(str_replace('\\', '/', $path), '/') == trim($relativePath, '/'))
            {
                $path = pathinfo($path);

                $relativePath = md5($path['dirname']).'/'.$path['basename'];
            }
        }

        return $relativePath;
    }
2389
protected function buildLocalLink($asset, $dir)
    {
        $collection = $this->assetIsFromCollection($asset);
        if ($collection !== false) {
            return $this->collections_dir.'/'.$collection[0].'/'.ltrim($dir, '/').'/'.$collection[1];
        }

        return parent::buildLocalLink($asset, $dir);
    }
472786
public static function assets($innerPath = '')
    {
        $path = 'assets';

        if (!empty($innerPath)) {
            $innerPath = untrailingslashit($innerPath);
            $path .= '/' . $innerPath;
        }

        return apply_filters('baobab/paths/assets', self::theme($path), $innerPath);
    }
724276
public function getUrl (string $assetPath) : string
    {
        return $this->assetUrl->generateUrl(
            Asset::createFromAssetPath($assetPath)
        );
    }
616673
public function asset_add_path($params) {
        if (!isset($params['path']))
            throw new \UnexpectedValueException('Asset path must be specified');
        $type = isset($params['type']) ? $params['type'] : null;
        Asset::add_path($params['path'], $type);
    }