diff --git a/app/code/Magento/Catalog/Block/Product/View/Gallery.php b/app/code/Magento/Catalog/Block/Product/View/Gallery.php
index f8b77d46d3ca7..e41e11ba10f98 100644
--- a/app/code/Magento/Catalog/Block/Product/View/Gallery.php
+++ b/app/code/Magento/Catalog/Block/Product/View/Gallery.php
@@ -112,7 +112,7 @@ public function isMainImage($image)
*/
public function getImageAttribute($imageId, $attributeName, $default = null)
{
- $attributes = $this->getConfigView()->getImageAttributes('Magento_Catalog', $imageId);
+ $attributes = $this->getConfigView()->getMediaAttributes('Magento_Catalog', 'images', $imageId);
return isset($attributes[$attributeName]) ? $attributes[$attributeName] : $default;
}
diff --git a/app/code/Magento/Catalog/Helper/Image.php b/app/code/Magento/Catalog/Helper/Image.php
index 00ab3f634498c..1d5056613cc57 100644
--- a/app/code/Magento/Catalog/Helper/Image.php
+++ b/app/code/Magento/Catalog/Helper/Image.php
@@ -172,7 +172,7 @@ public function init($product, $imageId, $attributes = [])
$this->attributes = array_merge(
$attributes,
- $this->getConfigView()->getImageAttributes('Magento_Catalog', $imageId)
+ $this->getConfigView()->getMediaAttributes('Magento_Catalog', 'images', $imageId)
);
$this->setProduct($product);
diff --git a/app/code/Magento/Catalog/Model/Product/Image/Cache.php b/app/code/Magento/Catalog/Model/Product/Image/Cache.php
index b1578af8a8c40..457e6ab6be418 100644
--- a/app/code/Magento/Catalog/Model/Product/Image/Cache.php
+++ b/app/code/Magento/Catalog/Model/Product/Image/Cache.php
@@ -64,7 +64,7 @@ protected function getData()
'area' => Area::AREA_FRONTEND,
'themeModel' => $theme,
]);
- $images = $config->getImages('Magento_Catalog');
+ $images = $config->getMediaEntities('Magento_Catalog', 'images');
foreach ($images as $imageId => $imageData) {
$this->data[$theme->getCode() . $imageId] = array_merge(['id' => $imageId], $imageData);
}
diff --git a/app/code/Magento/ProductVideo/Helper/Media.php b/app/code/Magento/ProductVideo/Helper/Media.php
index 9d89521993876..f3cc4bfea0253 100644
--- a/app/code/Magento/ProductVideo/Helper/Media.php
+++ b/app/code/Magento/ProductVideo/Helper/Media.php
@@ -35,6 +35,11 @@ class Media extends \Magento\Framework\App\Helper\AbstractHelper
*/
const NODE_CONFIG_VIDEO_AUTO_RESTART = 'video_auto_restart';
+ /**
+ * Media type
+ */
+ const MEDIA_TYPE = "videos";
+
/**
* @var ConfigInterface
*/
@@ -91,10 +96,16 @@ protected function initConfig()
*/
public function getPlayIfBaseAttribute()
{
- return $this->cachedVideoConfig->getVideoAttributeValue(
+ $videoAttributes = $this->cachedVideoConfig->getMediaAttributes(
self::MODULE_NAME,
+ self::MEDIA_TYPE,
self::NODE_CONFIG_PLAY_IF_BASE
);
+ if (isset($videoAttributes[self::NODE_CONFIG_PLAY_IF_BASE])) {
+ return $videoAttributes[self::NODE_CONFIG_PLAY_IF_BASE];
+ } else {
+ return null;
+ }
}
/**
@@ -104,10 +115,16 @@ public function getPlayIfBaseAttribute()
*/
public function getShowRelatedAttribute()
{
- return $this->cachedVideoConfig->getVideoAttributeValue(
+ $videoAttributes = $this->cachedVideoConfig->getMediaAttributes(
self::MODULE_NAME,
+ self::MEDIA_TYPE,
self::NODE_CONFIG_SHOW_RELATED
);
+ if (isset($videoAttributes[self::NODE_CONFIG_SHOW_RELATED])) {
+ return $videoAttributes[self::NODE_CONFIG_SHOW_RELATED];
+ } else {
+ return null;
+ }
}
/**
@@ -117,9 +134,15 @@ public function getShowRelatedAttribute()
*/
public function getVideoAutoRestartAttribute()
{
- return $this->cachedVideoConfig->getVideoAttributeValue(
+ $videoAttributes = $this->cachedVideoConfig->getMediaAttributes(
self::MODULE_NAME,
+ self::MEDIA_TYPE,
self::NODE_CONFIG_VIDEO_AUTO_RESTART
);
+ if (isset($videoAttributes[self::NODE_CONFIG_VIDEO_AUTO_RESTART])) {
+ return $videoAttributes[self::NODE_CONFIG_VIDEO_AUTO_RESTART];
+ } else {
+ return null;
+ }
}
}
diff --git a/app/code/Magento/ProductVideo/Model/VideoExtractor.php b/app/code/Magento/ProductVideo/Model/VideoExtractor.php
new file mode 100644
index 0000000000000..dfbf6eaf73d9d
--- /dev/null
+++ b/app/code/Magento/ProductVideo/Model/VideoExtractor.php
@@ -0,0 +1,34 @@
+getAttribute('module');
+ /** @var \DOMElement $node */
+ foreach ($childNode->getElementsByTagName('video') as $node) {
+ $imageId = $node->getAttribute('id');
+ $result[$childNode->tagName][$moduleName][$imageId]['type'] = $node->getAttribute('type');
+ foreach ($node->childNodes as $attribute) {
+ if ($attribute->nodeType != XML_ELEMENT_NODE) {
+ continue;
+ }
+ $nodeValue = $attribute->nodeValue;
+ $result[$childNode->tagName][$moduleName][$imageId][$attribute->tagName] = $nodeValue;
+ }
+ }
+ return $result;
+ }
+}
\ No newline at end of file
diff --git a/app/code/Magento/ProductVideo/etc/di.xml b/app/code/Magento/ProductVideo/etc/di.xml
index 64a91ddc217fc..fe72cc4096f32 100644
--- a/app/code/Magento/ProductVideo/etc/di.xml
+++ b/app/code/Magento/ProductVideo/etc/di.xml
@@ -14,6 +14,32 @@
+
+
+
+ -
+
-
+
- /view/videos
+ - module
+
+ -
+
- /view/videos/video
+ -
+
- id
+ - type
+
+
+
+
+
+
+
+
+
+ - Magento\ProductVideo\Model\VideoExtractor
+
+
+
diff --git a/app/code/Magento/ProductVideo/etc/view.xml b/app/code/Magento/ProductVideo/etc/view.xml
index e92e4139f2ec2..1f087617d90e3 100644
--- a/app/code/Magento/ProductVideo/etc/view.xml
+++ b/app/code/Magento/ProductVideo/etc/view.xml
@@ -5,8 +5,8 @@
* See COPYING.txt for license details.
*/
-->
-
-
+
+
@@ -16,5 +16,5 @@
-
+
diff --git a/app/code/Magento/ProductVideo/etc/view.xsd b/app/code/Magento/ProductVideo/etc/view.xsd
new file mode 100644
index 0000000000000..d404ca34abeed
--- /dev/null
+++ b/app/code/Magento/ProductVideo/etc/view.xsd
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Swatches/Helper/Media.php b/app/code/Magento/Swatches/Helper/Media.php
index 9a71c3b794085..52c114daa2d07 100644
--- a/app/code/Magento/Swatches/Helper/Media.php
+++ b/app/code/Magento/Swatches/Helper/Media.php
@@ -254,7 +254,7 @@ public function getImageConfig()
]);
$imageConfig = array_merge(
$imageConfig,
- $config->getImages('Magento_Catalog')
+ $config->getMediaEntities('Magento_Catalog', 'images')
);
}
return $imageConfig;
diff --git a/app/code/Magento/Swatches/Model/ImageExtractor.php b/app/code/Magento/Swatches/Model/ImageExtractor.php
new file mode 100644
index 0000000000000..169f6e8de99a9
--- /dev/null
+++ b/app/code/Magento/Swatches/Model/ImageExtractor.php
@@ -0,0 +1,35 @@
+getAttribute('module');
+ /** @var \DOMElement $node */
+ foreach ($childNode->getElementsByTagName('image') as $node) {
+ $imageId = $node->getAttribute('id');
+ $result[$childNode->tagName][$moduleName][$imageId]['type'] = $node->getAttribute('type');
+ foreach ($node->childNodes as $attribute) {
+ if ($attribute->nodeType != XML_ELEMENT_NODE) {
+ continue;
+ }
+ $nodeValue = $attribute->nodeValue;
+ $result[$childNode->tagName][$moduleName][$imageId][$attribute->tagName] = $nodeValue;
+ }
+ }
+ return $result;
+ }
+}
\ No newline at end of file
diff --git a/app/code/Magento/Swatches/etc/di.xml b/app/code/Magento/Swatches/etc/di.xml
index 1030cd4af02aa..3af0a64385c66 100644
--- a/app/code/Magento/Swatches/etc/di.xml
+++ b/app/code/Magento/Swatches/etc/di.xml
@@ -29,4 +29,30 @@
+
+
+
+ -
+
-
+
- /view/images
+ - module
+
+ -
+
- /view/images/image
+ -
+
- id
+ - type
+
+
+
+
+
+
+
+
+
+ - Magento\Swatches\Model\ImageExtractor
+
+
+
diff --git a/app/code/Magento/Swatches/etc/view.xml b/app/code/Magento/Swatches/etc/view.xml
index c70a0c3f9d099..b27c303b3fba7 100644
--- a/app/code/Magento/Swatches/etc/view.xml
+++ b/app/code/Magento/Swatches/etc/view.xml
@@ -5,8 +5,8 @@
* See COPYING.txt for license details.
*/
-->
-
-
+
+
30
20
@@ -23,5 +23,5 @@
110
90
-
+
diff --git a/app/code/Magento/Swatches/etc/view.xsd b/app/code/Magento/Swatches/etc/view.xsd
new file mode 100644
index 0000000000000..6524f566c6bdf
--- /dev/null
+++ b/app/code/Magento/Swatches/etc/view.xsd
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/design/adminhtml/Magento/backend/etc/view.xml b/app/design/adminhtml/Magento/backend/etc/view.xml
index ec6620fe6e1e2..f21fb7835311b 100644
--- a/app/design/adminhtml/Magento/backend/etc/view.xml
+++ b/app/design/adminhtml/Magento/backend/etc/view.xml
@@ -9,7 +9,7 @@
1MB
-
+
75
75
@@ -19,7 +19,7 @@
75
75
-
+
- Lib::mage/common.js
- Lib::mage/cookies.js
diff --git a/app/design/frontend/Magento/blank/etc/view.xml b/app/design/frontend/Magento/blank/etc/view.xml
index 6cda8d5b71bb8..4762130b12297 100644
--- a/app/design/frontend/Magento/blank/etc/view.xml
+++ b/app/design/frontend/Magento/blank/etc/view.xml
@@ -6,7 +6,7 @@
*/
-->
-
+
140
140
@@ -176,7 +176,7 @@
240
300
-
+
diff --git a/app/design/frontend/Magento/luma/etc/view.xml b/app/design/frontend/Magento/luma/etc/view.xml
index 7a272b88c11e8..57e50681c00ab 100644
--- a/app/design/frontend/Magento/luma/etc/view.xml
+++ b/app/design/frontend/Magento/luma/etc/view.xml
@@ -6,7 +6,7 @@
*/
-->
-
+
140
140
@@ -180,7 +180,7 @@
240
300
-
+
diff --git a/lib/internal/Magento/Framework/Config/Dom.php b/lib/internal/Magento/Framework/Config/Dom.php
index 1dbae5f157562..7de4348948000 100644
--- a/lib/internal/Magento/Framework/Config/Dom.php
+++ b/lib/internal/Magento/Framework/Config/Dom.php
@@ -129,15 +129,18 @@ protected function _mergeNode(\DOMElement $node, $parentPath)
/* Update matched node attributes and value */
if ($matchedNode) {
//different node type
- if ($this->_typeAttributeName && $node->hasAttribute(
- $this->_typeAttributeName
- ) && $matchedNode->hasAttribute(
- $this->_typeAttributeName
- ) && $node->getAttribute(
- $this->_typeAttributeName
- ) !== $matchedNode->getAttribute(
- $this->_typeAttributeName
- )
+ if ($this->_typeAttributeName
+ && $node->hasAttribute(
+ $this->_typeAttributeName
+ )
+ && $matchedNode->hasAttribute(
+ $this->_typeAttributeName
+ )
+ && $node->getAttribute(
+ $this->_typeAttributeName
+ ) !== $matchedNode->getAttribute(
+ $this->_typeAttributeName
+ )
) {
$parentMatchedNode = $this->_getMatchedNode($parentPath);
$newNode = $this->_dom->importNode($node, true);
@@ -225,7 +228,8 @@ protected function _getNodePathByParent(\DOMElement $node, $parentPath)
* Getter for node by path
*
* @param string $nodePath
- * @throws \Magento\Framework\Exception\LocalizedException An exception is possible if original document contains multiple nodes for identifier
+ * @throws \Magento\Framework\Exception\LocalizedException An exception is possible if original document contains
+ * multiple nodes for identifier
* @return \DOMElement|null
*/
protected function _getMatchedNode($nodePath)
@@ -250,19 +254,24 @@ protected function _getMatchedNode($nodePath)
* Validate dom document
*
* @param \DOMDocument $dom
- * @param string $schemaFileName
+ * @param string $schemaSource
* @param string $errorFormat
* @return array of errors
* @throws \Exception
*/
public static function validateDomDocument(
\DOMDocument $dom,
- $schemaFileName,
+ $schemaSource,
$errorFormat = self::ERROR_FORMAT_DEFAULT
) {
libxml_use_internal_errors(true);
try {
- $result = $dom->schemaValidate($schemaFileName);
+ if(file_exists($schemaSource)){
+ $result = $dom->schemaValidate($schemaSource);
+ }
+ else{
+ $result = $dom->schemaValidateSource($schemaSource);
+ }
$errors = [];
if (!$result) {
$validationErrors = libxml_get_errors();
diff --git a/lib/internal/Magento/Framework/Config/Reader/Xsd/MediaTypeDataExtractorInterface.php b/lib/internal/Magento/Framework/Config/Reader/Xsd/MediaTypeDataExtractorInterface.php
new file mode 100644
index 0000000000000..81dbbd77c467c
--- /dev/null
+++ b/lib/internal/Magento/Framework/Config/Reader/Xsd/MediaTypeDataExtractorInterface.php
@@ -0,0 +1,11 @@
+extractors = $extractors;
+ $this->objectManager = $objectManager;
+ }
+
+ /**
+ * Get node processor from corresponding module
+ *
+ * @param $tagName
+ * @return mixed
+ */
+ public function nodeProcessor($tagName)
+ {
+ return $this->objectManager->create($this->extractors[$tagName]);
+ }
+
+}
\ No newline at end of file
diff --git a/lib/internal/Magento/Framework/Config/Reader/Xsd/Reader.php b/lib/internal/Magento/Framework/Config/Reader/Xsd/Reader.php
new file mode 100644
index 0000000000000..fb4ea657e170d
--- /dev/null
+++ b/lib/internal/Magento/Framework/Config/Reader/Xsd/Reader.php
@@ -0,0 +1,149 @@
+directoryRead = $filesystem->getDirectoryRead(DirectoryList::MODULES);
+ $this->iteratorFactory = $iteratorFactory;
+ $this->fileName = $fileName;
+ $this->defaultScope = $defaultScope;
+ }
+
+ /**
+ * Get list of xsd files
+ *
+ * @param $filename
+ * @return \Magento\Framework\Config\FileIterator
+ */
+ public function getListXsdFiles($filename)
+ {
+ $iterator = $this->iteratorFactory->create(
+ $this->directoryRead,
+ $this->directoryRead->search('/*/*/etc/' . $filename)
+ );
+ return $iterator;
+ }
+
+ /**
+ * Read xsd files from list
+ *
+ * @param null $scope
+ * @return array|\Magento\Framework\Config\FileIterator
+ * @throws \Magento\Framework\Exception\LocalizedException
+ */
+ public function read($scope = null)
+ {
+ $fileList = $this->getListXsdFiles($this->fileName);
+ if (!count($fileList)) {
+ return [];
+ }
+ $mergeXsd = $this->readXsdFiles($fileList);
+
+ return $mergeXsd;
+ }
+
+ /**
+ * Get merged xsd file
+ *
+ * @param array $fileList
+ * @param string $baseXsd
+ * @return null|string
+ * @throws \Magento\Framework\Exception\LocalizedException
+ */
+ public function readXsdFiles($fileList, $baseXsd = null)
+ {
+ $baseXsd = new \DOMDocument();
+ $baseXsd->load(__DIR__ . '/../../etc/' . $this->fileName);
+ $configMerge = null;
+ foreach ($fileList as $key => $content) {
+ try {
+ if (!empty($content)) {
+ if ($configMerge) {
+ $configMerge = $this->mergeXsd($configMerge, $content);
+ } else {
+ $configMerge = $this->mergeXsd($baseXsd->saveXML(), $content);
+ }
+ }
+ } catch (\Magento\Framework\Config\Dom\ValidationException $e) {
+ throw new \Magento\Framework\Exception\LocalizedException(
+ new \Magento\Framework\Phrase("Invalid XSD in file %1:\n%2", [$key, $e->getMessage()])
+ );
+ }
+ }
+ return $configMerge;
+ }
+
+ /**
+ * Merge xsd files
+ *
+ * @param $parent
+ * @param $child
+ * @return string
+ */
+ function mergeXsd($parent, $child)
+ {
+ $domParent = new \DOMDocument("1.0", 'UTF-8');
+ $domParent->formatOutput = true;
+ $domParent->loadXML($parent);
+
+ $domChild = new \DOMDocument("1.0", 'UTF-8');
+ $domChild->formatOutput = true;
+ $domChild->loadXML($child);
+
+ $res1 = $domParent->getElementsByTagName('choice')->item(0);
+ $items2 = $domChild->getElementsByTagName('element')->item(1);
+ $item1 = $domParent->importNode($items2, true);
+ $res1->appendChild($item1);
+ $domChild = $domChild->documentElement;
+ $delete = $domChild->getElementsByTagName('element')->item(0);
+ $domChild->removeChild($delete);
+
+ foreach ($domChild->childNodes as $node) {
+ $importNode = $domParent->importNode($node, true);
+ $domParent->documentElement->appendChild($importNode);
+ }
+
+ return $domParent->saveXML();
+ }
+
+}
diff --git a/lib/internal/Magento/Framework/Config/View.php b/lib/internal/Magento/Framework/Config/View.php
index ab9b53bb0d142..441d871abacfd 100644
--- a/lib/internal/Magento/Framework/Config/View.php
+++ b/lib/internal/Magento/Framework/Config/View.php
@@ -9,16 +9,44 @@
*/
namespace Magento\Framework\Config;
+use Magento\Framework\Config\Reader\Xsd\Reader;
+use Magento\Framework\Config\Reader\Xsd\MediaTypeDataExtractorPool;
+
class View extends \Magento\Framework\Config\AbstractXml
{
+ /*
+ * @var \Magento\Framework\Config\Reader\Xsd\Reader
+ */
+ protected $xsdReader;
+
+ protected $extractorPool;
+
+ /*
+ * @var array
+ */
+ protected $xpath;
+
+ public function __construct(
+ $configFiles,
+ $xpath = [],
+ Reader $xsdReader,
+ MediaTypeDataExtractorPool $extractorPool
+ ) {
+ $this->xsdReader = $xsdReader;
+ $this->xpath = $xpath;
+ $this->extractorPool = $extractorPool;
+ parent::__construct($configFiles);
+ }
+
/**
- * Path to view.xsd
+ * Merged file view.xsd
*
* @return string
*/
public function getSchemaFile()
{
- return __DIR__ . '/etc/view.xsd';
+ $configXsd = $this->xsdReader->read();
+ return $configXsd;
}
/**
@@ -32,7 +60,10 @@ protected function _extractData(\DOMDocument $dom)
{
$result = [];
/** @var $varsNode \DOMElement */
- foreach ($dom->childNodes->item(0)/*root*/->childNodes as $childNode) {
+ foreach (
+ $dom->childNodes->item(0)/*root*/
+ ->childNodes as $childNode
+ ) {
switch ($childNode->tagName) {
case 'vars':
$moduleName = $childNode->getAttribute('module');
@@ -43,37 +74,6 @@ protected function _extractData(\DOMDocument $dom)
$result[$childNode->tagName][$moduleName][$varName] = $varValue;
}
break;
- break;
- case 'media':
- $moduleName = $childNode->getAttribute('module');
- /** @var \DOMElement $node */
- foreach ($childNode->getElementsByTagName('image') as $node) {
- $imageId = $node->getAttribute('id');
- $result[$childNode->tagName][$moduleName]['images'][$imageId]['type']
- = $node->getAttribute('type');
- foreach ($node->childNodes as $attribute) {
- if ($attribute->nodeType != XML_ELEMENT_NODE) {
- continue;
- }
- $nodeValue = $attribute->nodeValue;
- $result[$childNode->tagName][$moduleName]['images'][$imageId][$attribute->tagName]
- = $nodeValue;
- }
- }
- foreach ($childNode->getElementsByTagName('video') as $node) {
- $imageId = $node->getAttribute('id');
- $result[$childNode->tagName][$moduleName]['videos'][$imageId]['type']
- = $node->getAttribute('type');
- foreach ($node->childNodes as $attribute) {
- if ($attribute->nodeType != XML_ELEMENT_NODE) {
- continue;
- }
- $nodeValue = $attribute->nodeValue;
- $result[$childNode->tagName][$moduleName]['videos'][$imageId][$attribute->tagName]
- = $nodeValue;
- }
- }
- break;
case 'exclude':
/** @var $itemNode \DOMElement */
foreach ($childNode->getElementsByTagName('item') as $itemNode) {
@@ -81,6 +81,14 @@ protected function _extractData(\DOMDocument $dom)
$result[$childNode->tagName][$itemType][] = $itemNode->nodeValue;
}
break;
+ case 'images':
+ $imagesNodesArray = $this->extractorPool->nodeProcessor($childNode->tagName)->process($childNode);
+ $result = array_merge($result, $imagesNodesArray);
+ break;
+ case 'videos':
+ $videosNodesArray = $this->extractorPool->nodeProcessor($childNode->tagName)->process($childNode);
+ $result = array_merge($result, $videosNodesArray);
+ break;
}
}
return $result;
@@ -111,53 +119,30 @@ public function getVarValue($module, $var)
return isset($this->_data['vars'][$module][$var]) ? $this->_data['vars'][$module][$var] : false;
}
- /**
- * Retrieve a list videos attributes in scope of specified module
- *
- * @param string $module
- * @param string $var
- * @return mixed
- */
- public function getVideoAttributeValue($module, $var)
- {
- return isset($this->_data['media'][$module]['videos'][$var][$var])
- ? $this->_data['media'][$module]['videos'][$var][$var]
- : false;
- }
-
- /**
- * Retrieve a list images attributes in scope of specified module
- *
- * @param string $module
- * @return array
- */
- public function getImages($module)
- {
- return isset($this->_data['media'][$module]['images']) ? $this->_data['media'][$module]['images'] : [];
- }
-
/**
* Retrieve a list media attributes in scope of specified module
*
* @param string $module
+ * @param string $mediaType
* @return array
*/
- public function getMedia($module)
+ public function getMediaEntities($module, $mediaType)
{
- return isset($this->_data['media'][$module]) ? $this->_data['media'][$module] : [];
+ return isset($this->_data[$mediaType][$module]) ? $this->_data[$mediaType][$module] : [];
}
/**
- * Retrieve array of image attributes
+ * Retrieve array of media attributes
*
- * @param string $module
- * @param string $imageId
+ * @param $module
+ * @param $mediaType
+ * @param $mediaId
* @return array
*/
- public function getImageAttributes($module, $imageId)
+ public function getMediaAttributes($module, $mediaType, $mediaId)
{
- return isset($this->_data['media'][$module]['images'][$imageId])
- ? $this->_data['media'][$module]['images'][$imageId]
+ return isset($this->_data[$mediaType][$module][$mediaId])
+ ? $this->_data[$mediaType][$module][$mediaId]
: [];
}
@@ -179,7 +164,7 @@ public function getDomConfigCopy()
protected function _getInitialXml()
{
return '' .
- '';
+ '';
}
/**
@@ -189,14 +174,35 @@ protected function _getInitialXml()
*/
protected function _getIdAttributes()
{
- return [
+ $idAttributes = $this->addIdAttributes($this->xpath);
+ return $idAttributes;
+ }
+
+ /**
+ * Add attributes for module identification
+ *
+ * @param $xpath
+ * @return array
+ */
+ protected function addIdAttributes($xpath)
+ {
+ $idAttributes = [
'/view/vars' => 'module',
'/view/vars/var' => 'name',
'/view/exclude/item' => ['type', 'item'],
- '/view/media' => 'module',
- '/view/media/image' => ['id', 'type'],
- '/view/media/video' => ['id', 'type'],
];
+ if (is_array($xpath)) {
+ foreach ($xpath as $attribute) {
+ if (is_array($attribute)) {
+ foreach ($attribute as $newAttribute) {
+ if (isset($newAttribute['path']) && isset($newAttribute['id'])) {
+ $idAttributes[$newAttribute['path']] = $newAttribute['id'];
+ }
+ }
+ }
+ }
+ }
+ return $idAttributes;
}
/**
diff --git a/lib/internal/Magento/Framework/Config/ViewFactory.php b/lib/internal/Magento/Framework/Config/ViewFactory.php
new file mode 100644
index 0000000000000..7f523eeb36caa
--- /dev/null
+++ b/lib/internal/Magento/Framework/Config/ViewFactory.php
@@ -0,0 +1,45 @@
+objectManager = $objectManager;
+ }
+
+ /**
+ *
+ * Create View object
+ *
+ * @param array $arguments
+ * @return \Magento\Framework\Config\View
+ */
+ public function createView(array $arguments)
+ {
+ return $this->objectManager->create(self::CLASS_NAME, ["configFiles" => $arguments]);
+ }
+}
diff --git a/lib/internal/Magento/Framework/Config/etc/view.xsd b/lib/internal/Magento/Framework/Config/etc/view.xsd
index f036ab16d0621..23ccf2e41d5e6 100644
--- a/lib/internal/Magento/Framework/Config/etc/view.xsd
+++ b/lib/internal/Magento/Framework/Config/etc/view.xsd
@@ -29,7 +29,6 @@
-
@@ -38,61 +37,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/lib/internal/Magento/Framework/View/Config.php b/lib/internal/Magento/Framework/View/Config.php
index efb0f8978789d..35b7b6d1c7841 100644
--- a/lib/internal/Magento/Framework/View/Config.php
+++ b/lib/internal/Magento/Framework/View/Config.php
@@ -62,6 +62,13 @@ class Config implements \Magento\Framework\View\ConfigInterface
*/
protected $fileIteratorFactory;
+ /**
+ * File view factory
+ *
+ * @var \Magento\Framework\Config\ViewFactory
+ */
+ protected $viewFactory;
+
/**
* Constructor
*
@@ -78,6 +85,7 @@ public function __construct(
\Magento\Framework\View\Asset\Repository $assetRepo,
\Magento\Framework\View\FileSystem $viewFileSystem,
\Magento\Framework\Config\FileIteratorFactory $fileIteratorFactory,
+ \Magento\Framework\Config\ViewFactory $viewFactory,
$filename = self::CONFIG_FILE_NAME
) {
$this->moduleReader = $moduleReader;
@@ -86,6 +94,7 @@ public function __construct(
$this->viewFileSystem = $viewFileSystem;
$this->filename = $filename;
$this->fileIteratorFactory = $fileIteratorFactory;
+ $this->viewFactory = $viewFactory;
}
/**
@@ -118,7 +127,8 @@ public function getViewConfig(array $params = [])
$this->rootDirectory->getRelativePath($themeConfigFile)
);
}
- $config = new \Magento\Framework\Config\View($configFiles);
+
+ $config = $this->viewFactory->createView($configFiles);
$this->viewConfigs[$key] = $config;
return $config;