52 private $fallbackContext;
62 private $defaults =
null;
72 private $fallbackContextFactory;
77 private $contextFactory;
82 private $remoteFactory;
87 private $themeProvider;
103 \
Magento\Framework\View\Design\Theme\ListInterface $themeList,
111 $this->baseUrl = $baseUrl;
112 $this->design = $design;
114 $this->assetSource = $assetSource;
116 $this->fileFactory = $fileFactory;
117 $this->fallbackContextFactory = $fallbackContextFactory;
118 $this->contextFactory = $contextFactory;
119 $this->remoteFactory = $remoteFactory;
135 $params[
'area'] = $this->getDefaultParameter(
'area');
141 if (!empty(
$params[
'themeId'])) {
145 }
elseif (empty(
$params[
'themeModel']) &&
$area !== $this->getDefaultParameter(
'area')) {
146 $theme = $this->design->getConfigurationDesignTheme(
$area);
150 $params[
'themeModel'] = $this->getThemeProvider()->getThemeByFullPath(
$area .
'/' .
$theme);
152 throw new \UnexpectedValueException(
"Could not find theme '$theme' for area '$area'");
155 $params[
'themeModel'] = $this->getDefaultParameter(
'themeModel');
159 if (!array_key_exists(
'module',
$params)) {
164 if (empty(
$params[
'locale'])) {
165 $params[
'locale'] = $this->getDefaultParameter(
'locale');
173 private function getThemeProvider()
175 if (
null === $this->themeProvider) {
179 return $this->themeProvider;
188 private function getDefaultParameter(
$name)
190 $this->defaults = $this->design->getDesignParams();
191 return $this->defaults[
$name];
209 if (!isset(
$params[
'publish'])) {
210 $map = $this->getRepositoryFilesMap($fileId,
$params);
216 $isSecure = isset(
$params[
'_secure']) ? (bool)
$params[
'_secure'] :
null;
217 $themePath = isset(
$params[
'theme']) ?
$params[
'theme'] : $this->design->getThemePath(
$params[
'themeModel']);
218 $context = $this->getFallbackContext(
225 return $this->fileFactory->create(
227 'source' => $this->assetSource,
228 'context' => $context,
229 'filePath' => $filePath,
231 'contentType' => $this->assetSource->getContentType($filePath)
245 $themePath = $this->design->getThemePath(
$params[
'themeModel']);
246 $isSecure = $this->request->isSecure();
247 return $this->getFallbackContext(
268 private function getFallbackContext($urlType, $isSecure,
$area, $themePath,
$locale)
270 $secureKey =
null === $isSecure ?
'null' : (int)$isSecure;
272 $id = implode(
'|', [$baseDirType, $urlType, $secureKey,
$area, $themePath,
$locale]);
273 if (!isset($this->fallbackContext[
$id])) {
274 $url = $this->baseUrl->getBaseUrl([
'_type' => $urlType,
'_secure' => $isSecure]);
275 $this->fallbackContext[
$id] = $this->fallbackContextFactory->create(
279 'themePath' => $themePath,
284 return $this->fallbackContext[
$id];
300 return $this->fileFactory->create(
302 'source' => $this->assetSource,
304 'filePath' => $filePath,
306 'contentType' => $this->assetSource->getContentType($filePath)
329 $context = $this->getFileContext($baseDirType, $baseUrlType,
$dirPath);
330 $contentType = $this->assetSource->getContentType($filePath);
331 return $this->fileFactory->create(
333 'source' => $this->assetSource,
334 'context' => $context,
335 'filePath' => $filePath,
337 'contentType' => $contentType
352 private function getFileContext($baseDirType, $urlType,
$dirPath)
354 $id = implode(
'|', [$baseDirType, $urlType,
$dirPath]);
355 if (!isset($this->fileContext[
$id])) {
356 $url = $this->baseUrl->getBaseUrl([
'_type' => $urlType]);
357 $this->fileContext[
$id] = $this->contextFactory->create(
358 [
'baseUrl' =>
$url,
'baseDirType' => $baseDirType,
'contextPath' =>
$dirPath]
361 return $this->fileContext[
$id];
391 return $this->remoteFactory->create([
'url' =>
$url,
'contentType' => $contentType]);
403 return $asset->getUrl();
419 return $asset->getUrl();
431 if (strpos($fileId, self::FILE_ID_SEPARATOR) ===
false) {
432 return [
'', $fileId];
434 $result = explode(self::FILE_ID_SEPARATOR, $fileId, 2);
436 throw new \Magento\Framework\Exception\LocalizedException(
437 new \
Magento\Framework\
Phrase(
'Scope separator "::" cannot be used without scope identifier.')
448 private function getRepositoryFilesMap($fileId, array
$params)
451 return $repositoryMap->getMap($fileId,
$params);
createSimilar($fileId, LocalInterface $similarTo)
createAsset($fileId, array $params=[])
elseif(isset( $params[ 'redirect_parent']))
createArbitrary( $filePath, $dirPath, $baseDirType=DirectoryList::STATIC_VIEW, $baseUrlType=UrlInterface::URL_TYPE_STATIC)
static extractModule($fileId)
getStaticViewFileContext()
createRemoteAsset($url, $contentType)
__construct(\Magento\Framework\UrlInterface $baseUrl, \Magento\Framework\View\DesignInterface $design, \Magento\Framework\View\Design\Theme\ListInterface $themeList, \Magento\Framework\View\Asset\Source $assetSource, \Magento\Framework\App\Request\Http $request, FileFactory $fileFactory, File\FallbackContextFactory $fallbackContextFactory, File\ContextFactory $contextFactory, RemoteFactory $remoteFactory)
getUrlWithParams($fileId, array $params)
updateDesignParams(array &$params)
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
createRelated($fileId, LocalInterface $relativeTo)
static getRelatedPath($relativeTo, $path)
if(!isset($_GET['name'])) $name