Decorates an asset.

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

        return $asset;
    }
690
public function getRepository(AssetInterface $asset)
    {
        $assetRepositoryClassName = str_replace('\\Model\\', '\\Repository\\', get_class($asset)) . 'Repository';

        if (class_exists($assetRepositoryClassName)) {
            return $this->objectManager->get($assetRepositoryClassName);
        }

        return $this->objectManager->get(AssetRepository::class);
    }
1173556
public function isInUse(AssetInterface $asset)
    {
        /** @var AssetUsageStrategyInterface $strategy */
        foreach ($this->getUsageStrategies() as $strategy) {
            if ($strategy->isInUse($asset) === true) {
                return true;
            }
        }

        return false;
    }
1363626
protected function ensureByFilter(AssetInterface $asset, $filter)
    {
        if ($filter instanceof FilterInterface) {
            $filterInstance = $filter;
            $asset->ensureFilter($filterInstance);

            return;
        }

        $filterClass = $filter;

        if (!is_subclass_of($filterClass, 'Assetic\Filter\FilterInterface', true)) {
            $filterClass .= (substr($filterClass, -6) === 'Filter') ? '' : 'Filter';
            $filterClass  = 'Assetic\Filter\\' . $filterClass;
        }

        if (!class_exists($filterClass)) {
            throw new Exception\RuntimeException(
                'No filter found for ' . $filter
            );
        }

        if (!isset($this->filterInstances[$filterClass])) {
            $this->filterInstances[$filterClass] = new $filterClass();
        }

        $filterInstance = $this->filterInstances[$filterClass];

        $asset->ensureFilter($filterInstance);
    }
745825
public function relatedNodesAction(AssetInterface $asset)
    {
        $userWorkspace = $this->userService->getPersonalWorkspace();

        $usageReferences = $this->assetService->getUsageReferences($asset);
        $relatedNodes = [];
        $inaccessibleRelations = [];

        $existingSites = $this->siteRepository->findAll();

        foreach ($usageReferences as $usage) {
            $inaccessibleRelation = [
                'type' => get_class($usage),
                'usage' => $usage
            ];

            if (!$usage instanceof AssetUsageInNodeProperties) {
                $inaccessibleRelations[] = $inaccessibleRelation;
                continue;
            }

            try {
                $nodeType = $this->nodeTypeManager->getNodeType($usage->getNodeTypeName());
            } catch (NodeTypeNotFoundException $e) {
                $nodeType = null;
            }
            /** @var Workspace $workspace */
            $workspace = $this->workspaceRepository->findByIdentifier($usage->getWorkspaceName());
            $accessible = $this->domainUserService->currentUserCanReadWorkspace($workspace);

            $inaccessibleRelation['nodeIdentifier'] = $usage->getNodeIdentifier();
            $inaccessibleRelation['workspaceName'] = $usage->getWorkspaceName();
            $inaccessibleRelation['workspace'] = $workspace;
            $inaccessibleRelation['nodeType'] = $nodeType;
            $inaccessibleRelation['accessible'] = $accessible;

            if (!$accessible) {
                $inaccessibleRelations[] = $inaccessibleRelation;
                continue;
            }

            $node = $this->getNodeFrom($usage);
            // this should actually never happen.
            if (!$node) {
                $inaccessibleRelations[] = $inaccessibleRelation;
                continue;
            }

            $flowQuery = new FlowQuery([$node]);
            $documentNode = $flowQuery->closest('[instanceof Neos.Neos:Document]')->get(0);
            // this should actually never happen, too.
            if (!$documentNode) {
                $inaccessibleRelations[] = $inaccessibleRelation;
                continue;
            }

            $site = $node->getContext()->getCurrentSite();
            foreach ($existingSites as $existingSite) {
                /** @var Site $existingSite * */
                $siteNodePath = '/sites/' . $existingSite->getNodeName();
                if ($siteNodePath === $node->getPAth() || strpos($node->getPath(), $siteNodePath . '/') === 0) {
                    $site = $existingSite;
                }
            }

            $relatedNodes[$site->getNodeName()]['site'] = $site;
            $relatedNodes[$site->getNodeName()]['nodes'][] = [
                'node' => $node,
                'documentNode' => $documentNode
            ];
        }

        $this->view->assignMultiple([
            'totalUsageCount' => count($usageReferences),
            'nodeUsageClass' => AssetUsageInNodeProperties::class,
            'asset' => $asset,
            'inaccessibleRelations' => $inaccessibleRelations,
            'relatedNodes' => $relatedNodes,
            'contentDimensions' => $this->contentDimensionPresetSource->getAllPresets(),
            'userWorkspace' => $userWorkspace
        ]);
    }
679385
public function set($name, AssetInterface $asset)
    {
        if (!ctype_alnum(str_replace('_', '', $name))) {
            throw new \InvalidArgumentException(sprintf('The name "%s" is invalid.', $name));
        }

        $this->assets[$name] = $asset;
    }
525341
public function after($asset = null)
    {
        $movedAssets = $this->lastTouchedAssetsOrFail();

        if ($asset === null) {
            $this->moveAssetsToAppendings($this->lastTouchedGroup, $movedAssets);

            return $this;
        }

        $positionId = $this->positionId($asset);

        if (!isset($this->afters[$positionId])) {
            $this->afters[$positionId] = [];
        }

        $this->moveAssetsToPassedArray($this->afters[$positionId], $movedAssets);

        return $this;
    }
1134741
public function in(AssetManagerInterface $assetManager)
    {
        // Setup defaults.
        $assetManager->singleton(['dispatcher' => 'Proem\Dispatch\Dispatcher']);

        // Trigger an event allowing client code to override defaults.
        $assetManager->resolve('eventManager')->trigger(
            new Event('proem.in.init.dispatch'),
            function ($responseEvent) use ($assetManager) {
                // Check for a customized Dispatch\Dispatcher.
                if ($responseEvent instanceof Event && $responseEvent->has('dispatcherAsset')) {
                    $assetManager->overrideAsSingleton('dispatcher', $responseEvent->get('dispatcherAsset'));
                }
            }
        );

        // Trigger an event allowing client code to override the way the dispatcher is called.
        $assetManager->resolve('eventManager')->trigger(
            new Event('proem.in.dispatch'),
            function ($responseEvent) use ($assetManager) {
                // Check for a customised dispatch handler.
                if ($responseEvent instanceof Event && $responseEvent->has('dispatchHandler') && $responseEvent->get('dispatcherHandler') instanceof \Closure) {
                    $action = $responseEvent->get('dispatcherHandler');
                    $action($assetManager->resolve('request'));
                } else {
                    // Dispatch using the default handler.
                    $assetManager->resolve('dispatcher')->process($assetManager->resolve('request'));
                }
            }
        );
    }
1266588
public function locateAsset($asset)
    {
        if (substr($asset, 0, strlen($this->prefix)) === $this->prefix) {
            $locatedAsset = $this->resolveAlias($asset);
        } else {
            $locatedAsset = $asset;
        }

        if (!file_exists($locatedAsset)) {
            throw new AssetNotFoundException(sprintf('Asset not found (%s, resolved to %s)', $asset, $locatedAsset));
        }

        return $locatedAsset;
    }
1306581
public function setFilters($path, AssetInterface $asset)
    {
        $filters = $this->getFilters($path, $asset);

        foreach ($filters as $filter) {
            $this->setFilter($filter, $asset);
        }
    }
1134696
private function normalizeAsset(FileAssetInterface $asset)
    {
        $path = $asset->getPath();
        if ($path === null) {
            throw new \RuntimeException('Extension file assets must have a path set.');
        }

        if ($asset->getPackageName()) {
            return;
        }

        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();
        $filesystem = $app['filesystem'];

        $publicFile = $filesystem->getFile("web://$path");
        if ($publicFile->exists()) {
            $asset->setPackageName('web');

            return;
        }

        $themeFile = $filesystem->getFile("theme://$path");
        if ($themeFile->exists()) {
            $asset->setPackageName('theme');

            return;
        }

        $message = sprintf(
            "Couldn't add file asset '%s': File does not exist in %s, %s or %s directories. Make sure the file " .
            'exists in one of these locations, by placing the file there manually (for Bundled Extensions) or by ' .
            'uninstalling and reinstalling the extension again (for Managed Extensions).',
            $asset->getPath(),
            $file->getFullPath(),
            $publicFile->getFullPath(),
            $themeFile->getFullPath()
        );
        $app['logger.system']->error($message, ['event' => 'extensions']);
    }
1093662
public function assets(AssetFactory $asset)
    {
        $asset->load('jquery', [
            'type' => 'script',
        ])->area('admin');

        $asset->load('wp-color-picker', [
            'type' => 'style',
        ])->area('admin');

        $asset->add('fielder-colorpicker-styles', [
            'path' => FIELDER_URI.'public/css/colorpicker.css',
        ])->area('admin');

        $asset->add('fielder-colorpicker', [
            'path' => FIELDER_URI.'public/js/colorpicker.js',
            'dependences' => ['fielder', 'wp-color-picker'],
        ])->area('admin');
    }
1264332
protected function _resolveDependencies(Asset $asset, &$resolved = [], &$unresolved = [])
    {
        $unresolved[$asset->getAlias()] = $asset;

        foreach ($asset->getDependencies() as $dependency) {
            if (!Arr::key($dependency, $resolved)) {

                if (isset($unresolved[$dependency])) {
                    throw new Exception(sprintf(
                        'Circular asset dependency "%s > %s" detected.',
                        $asset->getAlias(),
                        $dependency
                    ));
                }

                if ($dep = $this->_collection->get($dependency)) {
                    $this->_resolveDependencies($dep, $resolved, $unresolved);
                } else {
                    throw new Exception("Undefined depends: $dependency");
                }
            }
        }

        $resolved[$asset->getAlias()] = $asset;
        unset($unresolved[$asset->getAlias()]);

        return $resolved;
    }
1344466
public function filterLoad(AssetInterface $asset)
    {
        $root = $asset->getSourceRoot();
        $path = $asset->getSourcePath();

        $compiler = new \SassParser($this->presets);

        if ($root and $path) {
            $compiler->load_paths = array_merge($compiler->load_paths, array($root.'/'.$path));
        }

        $compiler->load_paths = array_merge($compiler->load_paths, $this->importPaths);

        $asset->setContent($compiler->toCss($asset->getContent(), false));
    }
820440
public function registerRemovedAsset(AssetInterface $asset)
    {
        $assetIdentifier = $this->persistenceManager->getIdentifierByObject($asset);
        $importedAsset = $this->importedAssetRepository->findOneByLocalAssetIdentifier($assetIdentifier);
        if ($importedAsset !== null) {
            $this->importedAssetRepository->remove($importedAsset);
            $this->logger->debug(sprintf('Asset removed: %s / %s', $asset->getResource()->getFilename(), $this->persistenceManager->getIdentifierByObject($asset)));
        }
    }
755136
public function registerAsset($context, $asset)
    {
        return $this->resolveAndCall($asset, 'register', [
            isset($context['this']) ? $context['this'] : null,
        ]);
    }
1135934
public function set($index, AssetInterface $asset)
    {
        $this->data[$index] = $asset;
        $this->provides[]   = $asset->is();
        return $this;
    }