Filters an asset after it has been loaded.

@param  \Assetic\Asset\AssetInterface  $asset
@return void
323440
public function filterLoad(AssetInterface $asset)
    {
        $max_nesting_level = ini_get('xdebug.max_nesting_level');

        $memory_limit = ini_get('memory_limit');

        if ($max_nesting_level && $max_nesting_level < 200) {
            ini_set('xdebug.max_nesting_level', 200);
        }

        if ($memory_limit && $memory_limit < 256) {
            ini_set('memory_limit', '256M');
        }

        $root = $asset->getSourceRoot();
        $path = $asset->getSourcePath();

        $dirs = array();

        $lc = new \Less_Parser(array(
            'compress' => true,
        ));

        if ($root && $path) {
            $dirs[] = dirname($root.'/'.$path);
        }

        foreach ($this->loadPaths as $loadPath) {
            $dirs[] = $loadPath;
        }

        $lc->SetImportDirs($dirs);

        $url = parse_url($this->getRequest()->getUriForPath(''));

        // Strip the document root from the path.
        if (strpos($root, app('path.public')) !== false) {
            $absolutePath = str_replace(app('path.public'), '', $root);
        } elseif (strpos($root, app('path.resources')) !== false) {
            $absolutePath = str_replace(app('path.resources'), '', $root);
        }

        if (isset($url['path'])) {
            $absolutePath = $url['path'] . $absolutePath;
        }

        $lc->parseFile($root.'/'.$path, $absolutePath);

        $asset->setContent($lc->getCss());
    }
601113
public function clear( $type = null ) 
	{
		if ( is_null( $type ) )
		{
			$this->assets = array();
		}
		else
		{
			if ( isset( $this->assets[$type] ) )
			{
				$this->assets[$type] = array();
			}
		}
	}
1106004
public function delete( $file ) {
		$key = array_search( $file, $this->assets[ $this->type ] );
		unset( $this->assets[ $this->type ][ $key ] );
		unset( $this->attr[ $this->type ][ $key ] );
	}
158060
public function add(FileAssetInterface $asset)
    {
        if (!$asset->getPackageName()) {
            // Deprecated.
            $asset->setPackageName('extensions');
        }

        $key = $asset->getPackageName()."/".$asset->getPath();

        if ($asset->getType() === 'javascript') {
            $this->javascript[$key] = $asset;
        } elseif ($asset->getType() === 'stylesheet') {
            $this->stylesheet[$key] = $asset;
        } else {
            throw new \InvalidArgumentException(sprintf('Requested asset type %s is not valid.', $asset->getType()));
        }
    }
1097188
private function addAsset(AssetInterface $asset)
    {
        if ($asset instanceof FileAssetInterface) {
            $this->normalizeAsset($asset);
        }
        $this->assets[] = $asset;
    }
995904
public function purge (Asset $asset)
    {
        $url = $this->getImgixUrl($asset);

        Craft::trace(
            Craft::t(
                'imgix',
                'Purging asset #{id}: {url}', [ 'id' => $asset->id, 'url' => $url ]
            ),
            'imgix');

        return $this->purgeUrl($url);
    }
1132605
public function registerAssetChange(AssetInterface $asset)
    {
        if (!$asset->isInUse()) {
            return;
        }

        $cachingHelper = $this->getCachingHelper();

        foreach ($this->assetService->getUsageReferences($asset) as $reference) {
            if (!$reference instanceof AssetUsageInNodeProperties) {
                continue;
            }

            $workspaceHash = $cachingHelper->renderWorkspaceTagForContextNode($reference->getWorkspaceName());

            $this->registerChangeOnNodeIdentifier($workspaceHash . '_' . $reference->getNodeIdentifier());
            $this->registerChangeOnNodeType($reference->getNodeTypeName(), $reference->getNodeIdentifier(), $workspaceHash);

            $assetIdentifier = $this->persistenceManager->getIdentifierByObject($asset);

            $tagName = 'AssetDynamicTag_' . $workspaceHash . '_' . $assetIdentifier;
            $this->tagsToFlush[$tagName] = sprintf('which were tagged with "%s" because asset "%s" has changed.', $tagName, $assetIdentifier);
        }
    }
828741
public function onLoaded(ResourceInterface $resource)
    {
        if (!$this->isDebugging() || $this->current === $resource) {
            return;
        }

        $this->ensureCollector($this->current);
        $this->meta[$this->current]->addResource($resource);
    }
918265
public function getForAsset(AssetInterface $asset)
    {
        $sourceRoot = $asset->getSourceRoot();
        if (!isset($this->bundleMap[$sourceRoot])) {
            throw new \Exception('Could not map the asset to a bundle');
        }

        // get the relative path
        $templateName = $asset->getSourcePath();
        // by convention, all symfony views are in Resources/views/, therefore remove this segment
        $templateName = str_replace('Resources/views/', '', $templateName);
        // remove the .ng extension (our convention)
        $templateName = str_replace('.ng', '', $templateName);
        // prepend bundle name
        $bundleName = $this->bundleMap[$sourceRoot];
        $templateName = sprintf('%s/%s', $bundleName, $templateName);

        return $templateName;
    }
423768
public function setCache($path, AssetInterface $asset)
    {
        $provider = $this->getProvider($path);

        if (!$provider instanceof CacheInterface) {
            return $asset;
        }

        $assetCache             = new AssetCache($asset, $provider);
        $assetCache->mimetype   = $asset->mimetype;

        return $assetCache;
    }
925616
public function getUsageCount(AssetInterface $asset)
    {
        $usageCount = 0;
        /** @var AssetUsageStrategyInterface $strategy */
        foreach ($this->getUsageStrategies() as $strategy) {
            $usageCount += $strategy->getUsageCount($asset);
        }

        return $usageCount;
    }
1130014
private function applyWorkers(AssetCollectionInterface $asset)
    {
        foreach ($asset as $leaf) {
            foreach ($this->workers as $worker) {
                $retval = $worker->process($leaf, $this);

                if ($retval instanceof AssetInterface && $leaf !== $retval) {
                    $asset->replaceLeaf($leaf, $retval);
                }
            }
        }

        foreach ($this->workers as $worker) {
            $retval = $worker->process($asset, $this);

            if ($retval instanceof AssetInterface) {
                $asset = $retval;
            }
        }

        return $asset instanceof AssetCollectionInterface ? $asset : $this->createAssetCollection(array($asset));
    }
488766
protected function protectAll($assets)
    {
        if (empty($assets)) {
            return;
        }
        $store = $this->getAssetStore();
        foreach ($assets as $asset) {
            $store->protect($asset['Filename'], $asset['Hash']);
        }
    }
760245
private function includeThis(AssetInterface $asset_holder)
    {

        // include the included directories
        $this->in($asset_holder->getIncludedDirectories());

        // include files with this extensions
        foreach ($asset_holder->getIncludedExtensions() as $extension) {
            $this->name('*'.$extension);
        }

        // include patterns
        foreach ($asset_holder->getIncludedPatterns() as $pattern) {
            $this->name($pattern);
        }

        // exclude ignored directories
        $this->exclude($asset_holder->getExcludedDirectories());
    }
518539
public function getUsageReferences(AssetInterface $asset)
    {
        $assetIdentifier = $this->persistenceManager->getIdentifierByObject($asset);
        if (isset($this->firstlevelCache[$assetIdentifier])) {
            return $this->firstlevelCache[$assetIdentifier];
        }

        $relatedNodes = array_map(function (NodeData $relatedNodeData) use ($asset) {
            return new AssetUsageInNodeProperties($asset,
                $relatedNodeData->getIdentifier(),
                $relatedNodeData->getWorkspace()->getName(),
                $relatedNodeData->getDimensionValues(),
                $relatedNodeData->getNodeType()->getName()
            );
        }, $this->getRelatedNodes($asset));

        $this->firstlevelCache[$assetIdentifier] = $relatedNodes;
        return $this->firstlevelCache[$assetIdentifier];
    }
224563
public function filterDump(AssetInterface $asset)
    {
        $pb = $this->createProcessBuilder($this->nodeBin
            ? array($this->nodeBin, $this->cleanCssBin)
            : array($this->cleanCssBin));

        if ($this->keepLineBreaks) {
            $pb->add('--keep-line-breaks');
        }

        if ($this->compatibility) {
            $pb->add('--compatibility ' .$this->compatibility);
        }

        if ($this->debug) {
            $pb->add('--debug');
        }

        if ($this->rootPath) {
            $pb->add('--root ' .$this->rootPath);
        }

        if ($this->skipImport) {
            $pb->add('--skip-import');
        }

        if ($this->timeout) {
            $pb->add('--timeout ' .$this->timeout);
        }

        if ($this->roundingPrecision) {
            $pb->add('--rounding-precision ' .$this->roundingPrecision);
        }

        if ($this->removeSpecialComments) {
            $pb->add('--s0');
        }

        if ($this->onlyKeepFirstSpecialComment) {
            $pb->add('--s1');
        }

        if ($this->semanticMerging) {
            $pb->add('--semantic-merging');
        }

        if ($this->skipAdvanced) {
            $pb->add('--skip-advanced');
        }

        if ($this->skipAggresiveMerging) {
            $pb->add('--skip-aggressive-merging');
        }

        if ($this->skipImportFrom) {
            $pb->add('--skip-import-from ' .$this->skipImportFrom);
        }

        if ($this->mediaMerging) {
            $pb->add('--skip-media-merging');
        }

        if ($this->skipRebase) {
            $pb->add('--skip-rebase');
        }

        if ($this->skipRestructuring) {
            $pb->add('--skip-restructuring');
        }

        if ($this->skipShorthandCompacting) {
            $pb->add('--skip-shorthand-compacting');
        }

        if ($this->sourceMap) {
            $pb->add('--source-map');
        }

        if ($this->sourceMapInlineSources) {
            $pb->add('--source-map-inline-sources');
        }
        // input and output files
        $input = tempnam(sys_get_temp_dir(), 'input');

        file_put_contents($input, $asset->getContent());
        $pb->add($input);

        $proc = $pb->getProcess();
        $code = $proc->run();
        unlink($input);

        if (127 === $code) {
            throw new \RuntimeException('Path to node executable could not be resolved.');
        }

        if (0 !== $code) {
            throw FilterException::fromProcess($proc)->setInput($asset->getContent());
        }

        $asset->setContent($proc->getOutput());
    }
514648
public function decorate(AssetInterface $asset)
    {
        foreach ($this->decorators as $decorator) {
            /**
             * @var AssetDecoratorInterface $decorator
             */
            $asset = $decorator->decorate($asset);
        }

        return $asset;
    }