Bolt\Extension\AssetTrait::normalizeAsset PHP Метод

normalizeAsset() приватный Метод

Normalizes the path and package name of the asset file.
private normalizeAsset ( Bolt\Asset\File\FileAssetInterface $asset )
$asset Bolt\Asset\File\FileAssetInterface
    private function normalizeAsset(FileAssetInterface $asset)
    {
        $path = $asset->getPath();
        if ($path === null) {
            throw new \RuntimeException('Extension file assets must have a path set.');
        }
        if ($this->isAbsoluteUrl($path)) {
            // Set asset to a package, since there is no default.
            // It doesn't matter which since it is absolute.
            $asset->setPackageName('extensions');
            return;
        }
        $file = $this->getWebDirectory()->getFile($asset->getPath());
        if ($file->exists()) {
            $asset->setPackageName('extensions')->setPath($file->getPath());
            return;
        }
        $app = $this->getContainer();
        $themeFile = $app['filesystem']->getFile(sprintf('theme://%s', $path));
        if ($themeFile->exists()) {
            $asset->setPackageName('theme')->setPath($path);
            return;
        }
        $message = sprintf("Couldn't add file asset '%s': File does not exist in either %s or %s directories.", $path, $this->getWebDirectory()->getFullPath(), $themeFile->getFullPath());
        $app['logger.system']->error($message, ['event' => 'extensions']);
    }