@param string $assetType
@param string $assetHandle

@return Asset
11844
public function getAsset($assetType, $assetHandle)
    {
        return isset($this->assets[$assetType][$assetHandle]) ? $this->assets[$assetType][$assetHandle] : null;
    }
533606
public function compile($assets, $type) {

        $self = $this;

        $rewriteCssUrls = function($content, $asset) use($self) {

            $source_dir = dirname($asset["file"]);
            $root_dir   = $self->app['docs_root'];

            $csspath  = "";

            if (strlen($root_dir) < strlen($source_dir)) {
                $csspath = '/'.trim(str_replace($root_dir, '', $source_dir), "/")."/";
            } else {
                // todo
            }

            $offset = 0;

            while(($pos = strpos($content, 'url(', $offset)) !== false){

                if(($urlend = strpos($content, ')', $pos))!==false) {

                    $path = trim(str_replace(array('"', "'"), "", substr($content, $pos+4, $urlend-($pos+4))));

                    if(!preg_match("#^(http|/|data\:)#",trim($path))){
                        $content = str_replace($path, $csspath.$path, $content);
                    }
                }

                $offset = $pos + 1;
            }


            return $content;
        };

        $output = array();

        foreach ((array)$assets as $file) {

            $asset = array(
                "ext"  => pathinfo($file, PATHINFO_EXTENSION),
                "file" => $file
            );

            $ext     = $asset['ext'];
            $content = '';

            if (strpos($file, ':') !== false && $____file = $this->app->path($file)) {
                $asset['file'] = $file = $____file;
            }

            if($ext!=$type) continue;

            switch ($asset['ext']) {

                case 'js':

                    $content = @file_get_contents($file);
                    break;

                case 'css':

                    $content = @file_get_contents($file);
                    $content = $rewriteCssUrls($content, $asset);

                    break;

                default:
                    continue;
            }
            
            // Remove references to source maps
            $content = preg_replace('~/[/|\*]# sourceMappingURL=.*~', '', $content);

            $output[] = $content;
        }

        // Add newlines between files to fix problem with stacking comments.
        return implode("\n", $output);
    }
1079561
public function variantsAction(string $assetSourceIdentifier, string $assetProxyIdentifier, string $overviewAction): void
    {
        if (!isset($this->assetSources[$assetSourceIdentifier])) {
            throw new \RuntimeException('Given asset source is not configured.', 1509632166);
        }

        $assetSource = $this->assetSources[$assetSourceIdentifier];
        $assetProxyRepository = $assetSource->getAssetProxyRepository();

        try {
            $assetProxy = $assetProxyRepository->getAssetProxy($assetProxyIdentifier);
            $asset = $this->persistenceManager->getObjectByIdentifier($assetProxy->getLocalAssetIdentifier(), Asset::class);

            /** @var VariantSupportInterface $originalAsset */
            $originalAsset = ($asset instanceof AssetVariantInterface ? $asset->getOriginalAsset() : $asset);

            $variantInformation = array_map(static function (AssetVariantInterface $imageVariant) {
                return (new ImageMapper($imageVariant))->getMappingResult();
            }, $originalAsset->getVariants());

            $this->view->assignMultiple([
                'assetProxy' => $assetProxy,
                'asset' => $originalAsset,
                'assetSource' => $assetSource,
                'imageProfiles' => $this->imageProfilesConfiguration,
                'overviewAction' => $overviewAction,
                'originalInformation' => (new ImageMapper($asset))->getMappingResult(),
                'variantsInformation' => $variantInformation
            ]);
        } catch (AssetNotFoundExceptionInterface $e) {
            $this->throwStatus(404, 'Original asset not found');
        } catch (AssetSourceConnectionExceptionInterface $e) {
            $this->view->assign('connectionError', $e);
        }
    }
62693
public function setType(string $type): AssetInterface
    {
        $path = $this->file->isExternal() ? $this->getUrl() : $this->getPath();

        $this->file->setType($path, $type);

        return $this;
    }
615809
protected function getAsset($assetData)
    {
        try {
            $Comet = \CometPHP\Comet::getInstance();
        } catch (\CometPHP\Exceptions\CometNotBooted $e) {
            return null;
        }

        if (! is_array($assetData)) {
            $assetData = [$assetData];
        }

        $asset = $Comet['template']->getFunction('asset')->call(
            $this->template,
            $assetData
        );

        return $asset;
    }
646538
public function getAssetRenderer($baseUrl = null, $basePath = null)
    {
        if ($this->jsRenderer === null) {
            $this->jsRenderer = new AssetsRenderer($this, $baseUrl, $basePath);
        }

        return $this->jsRenderer;
    }
526158
public function setType(string $filename, $type = null): AssetFileInterface
    {
        if (! is_null($type) && in_array($type, $this->extensions, true)) {
            // We first listen to a defined asset type.
            // If no type is defined, let's try to discover it.
            $this->type = $this->findType($type);

            return $this;
        }

        $ext = $this->files->extension($filename);

        if (! empty($ext) && in_array($ext, $this->extensions, true)) {
            $this->type = $this->findType($ext);
        }

        return $this;
    }
867681
private function addAsset (Asset $asset) : Asset
    {
        $storage = $this->locator->get(AssetStorage::class);
        $cache = $this->locator->get(AssetsCache::class);

        $asset = $storage->import($asset);
        $cache->add($asset);

        return $asset;
    }
633848
public function getUrlAssetUrls($url, array $assetTypes = ['image'], $siteId = null): array
    {
        $devMode = Craft::$app->getConfig()->getGeneral()->devMode;
        $cache = Craft::$app->getCache();

        // Extract a URI from the URL
        $uri = parse_url($url, PHP_URL_PATH);
        $uri = ltrim($uri, '/');
        // Set up our cache criteria
        $cacheKey = $this->getCacheKey($this::ROUTEMAP_ASSET_URLS, [$uri, $assetTypes, $siteId]);
        $duration = $devMode ? $this::DEVMODE_ROUTEMAP_CACHE_DURATION : $this::ROUTEMAP_CACHE_DURATION;
        $dependency = new TagDependency([
            'tags' => [
                $this::ROUTEMAP_CACHE_TAG,
            ],
        ]);

        // Just return the data if it's already cached
        $assetUrls = $cache->getOrSet($cacheKey, function () use ($uri, $assetTypes, $siteId) {
            Craft::info(
                'Route Map cache miss: '.$uri,
                __METHOD__
            );
            $resultingAssetUrls = [];

            // Find the element that matches this URI
            $element = Craft::$app->getElements()->getElementByUri($uri, $siteId, true);
            /** @var  $element Entry */
            if ($element) {
                // Iterate any Assets fields for this entry
                $assetFields = FieldHelper::fieldsOfType($element, AssetsField::class);
                foreach ($assetFields as $assetField) {
                    $assets = $element[$assetField]->all();
                    /** @var Asset[] $assets */
                    foreach ($assets as $asset) {
                        /** @var $asset Asset */
                        if (\in_array($asset->kind, $assetTypes, true)
                            && !\in_array($asset->getUrl(), $resultingAssetUrls, true)) {
                            $resultingAssetUrls[] = $asset->getUrl();
                        }
                    }
                }
                // Iterate through any Assets embedded in Matrix fields
                $matrixFields = FieldHelper::fieldsOfType($element, MatrixField::class);
                foreach ($matrixFields as $matrixField) {
                    $matrixBlocks = $element[$matrixField]->all();
                    /** @var MatrixBlock[] $matrixBlocks */
                    foreach ($matrixBlocks as $matrixBlock) {
                        $assetFields = FieldHelper::matrixFieldsOfType($matrixBlock, AssetsField::class);
                        foreach ($assetFields as $assetField) {
                            foreach ($matrixBlock[$assetField] as $asset) {
                                /** @var $asset Asset */
                                if (\in_array($asset->kind, $assetTypes, true)
                                    && !\in_array($asset->getUrl(), $resultingAssetUrls, true)) {
                                    $resultingAssetUrls[] = $asset->getUrl();
                                }
                            }
                        }
                    }
                }
            }

            return $resultingAssetUrls;
        }, $duration, $dependency);


        return $assetUrls;
    }
1128894
protected function applyTypeSpecificHandling($asset, $source, array $convertedChildProperties, PropertyMappingConfigurationInterface $configuration)
    {
        if ($asset instanceof ImageVariant) {
            $adjustments = [];
            if (isset($source['adjustments'])) {
                foreach ($source['adjustments'] as $adjustmentType => $adjustmentOptions) {
                    if (isset($adjustmentOptions['__type'])) {
                        $adjustmentType = $adjustmentOptions['__type'];
                        unset($adjustmentOptions['__type']);
                    }
                    $identity = null;
                    if (isset($adjustmentOptions['__identity'])) {
                        $identity = $adjustmentOptions['__identity'];
                        unset($adjustmentOptions['__identity']);
                    }

                    $adjustment = $this->propertyMapper->convert($adjustmentOptions, $adjustmentType, $configuration);
                    if ($identity !== null) {
                        ObjectAccess::setProperty($adjustment, 'persistence_object_identifier', $identity, true);
                    }

                    $adjustments[] = $adjustment;
                }
            } elseif (isset($source['processingInstructions'])) {
                $adjustments = $this->processingInstructionsConverter->convertFrom($source['processingInstructions'], 'array');
            }

            if (count($adjustments) > 0) {
                $asset->addAdjustments($adjustments);
            }
        }

        return $asset;
    }
1221692
public function moduleAsset($module, $path, $contentType = 'null')
    {
        $assetPath = base_path(Config::get('cms.module-directory').'/'.ucfirst($module).'/Assets/'.$path);

        if (!is_file($assetPath)) {
            $assetPath = config('cms.modules.'.$module.'.asset_path').'/'.$path;
        }

        return url(config('cms.backend-route-prefix', 'cms').'/asset/'.CryptoServiceFacade::url_encode($assetPath).'/'.CryptoServiceFacade::url_encode($contentType).'/?isModule=true');
    }
423195
public function asset_js($params) {
        if (!isset($params['refs'])) {
            throw new \UnexpectedValueException("The refs parameter is required.");
        }
        $group = isset($params['group']) ? $params['group'] : null;
        $attrs = isset($params['attrs']) ? $params['attrs'] : array();
        $raw = isset($params['raw']) ? $params['raw'] : false;
        return Asset::js($params['refs'], $attrs, $group, $raw);
    }
366197
protected function getAssetType($asset, array $availables, $type)
    {
        $type = null === $type
            ? $this->findAssetType($asset, $availables)
            : $this->formatAssetType($type);

        if (null !== $type) {
            return $type;
        }

        throw new InvalidArgumentException(sprintf('The asset type is required for the asset "%s"', $asset));
    }
793173
public function getAsset($asset)
    {
        if (!isset($this->assetCache[$asset])) {
            $this->assetCache[$asset] = $this->assetRepository->createAsset($asset);
        }
        return $this->assetCache[$asset];
    }
161176
public function getAssetType(string $assetType) : AssetTypeInterface
    {
        if (!isset($this->assetTypes[$assetType])) {
            if (isset($this->assetTypesArray[$assetType])) {
                $this->assetTypes[$assetType] = ImmutableAssetType::fromArray($assetType, $this->assetTypesArray[$assetType]);
            } else {
                $this->assetTypes[$assetType] = ImmutableAssetType::fromArray($assetType, []);
            }
        }
        return $this->assetTypes[$assetType];
    }
752160
public function read(AssetInterface $asset_holder)
    {
        /*
         * add the included directories and files
         */
        $this->includeThis($asset_holder);
        /*
         * exclude the ignored directories and files
         */
        $this->excludeThis($asset_holder);

        // user terminal message
        $this->console->writeln('<fg=yellow>Files to upload:</fg=yellow>');

        // get all allowed 'for upload' files objects (assets) and store them in an array
        $assets = [];
        foreach ($this->files() as $file) {
            // user terminal message
            $this->console->writeln('<fg=cyan>'.'Path: '.$file->getRealpath().'</fg=cyan>');

            $assets[] = $file;
        }

        return new Collection($assets);
    }
473813
public function asset($encPath, $contentType, Filesystem $fileSystem)
    {
        return $this->service->asset($encPath, $contentType, $fileSystem);
    }