-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PV-5: Code refactoring for merge xsd schema
- Loading branch information
Dmitry Kologrivov
committed
Sep 28, 2015
1 parent
36ddf4f
commit f3a12f2
Showing
24 changed files
with
621 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\ProductVideo\Model; | ||
|
||
class VideoExtractor implements \Magento\Framework\Config\Reader\Xsd\MediaTypeDataExtractorInterface | ||
{ | ||
/** | ||
* Extract configuration data of videos from the DOM structure | ||
* | ||
* @param \DOMElement $childNode | ||
* @return array | ||
*/ | ||
public function process(\DOMElement $childNode) | ||
{ | ||
$result = []; | ||
$moduleName = $childNode->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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> | ||
<xs:element name="view"> | ||
<xs:complexType> | ||
<xs:choice maxOccurs="unbounded"> | ||
<xs:element name="videos" minOccurs="0" type="videosType"/> | ||
</xs:choice> | ||
</xs:complexType> | ||
</xs:element> | ||
<xs:complexType name="videosType"> | ||
<xs:sequence> | ||
<xs:element name="video" minOccurs="0" maxOccurs="unbounded"> | ||
<xs:complexType> | ||
<xs:sequence> | ||
<xs:element name="play_if_base" type="xs:boolean" minOccurs="0"/> | ||
<xs:element name="show_related" type="xs:boolean" minOccurs="0"/> | ||
<xs:element name="video_auto_restart" type="xs:boolean" minOccurs="0"/> | ||
</xs:sequence> | ||
<xs:attribute name="id" type="xs:string" use="required"/> | ||
<xs:attribute name="type" use="required"> | ||
<xs:simpleType> | ||
<xs:restriction base="xs:string"> | ||
<xs:enumeration value="play_if_base"/> | ||
<xs:enumeration value="show_related"/> | ||
<xs:enumeration value="video_auto_restart"/> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
</xs:attribute> | ||
</xs:complexType> | ||
</xs:element> | ||
</xs:sequence> | ||
<xs:attribute name="module" type="xs:string" use="required"/> | ||
</xs:complexType> | ||
</xs:schema> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Swatches\Model; | ||
|
||
|
||
class ImageExtractor implements \Magento\Framework\Config\Reader\Xsd\MediaTypeDataExtractorInterface | ||
{ | ||
/** | ||
* Extract configuration data of images from the DOM structure | ||
* | ||
* @param \DOMElement $childNode | ||
* @return array | ||
*/ | ||
public function process(\DOMElement $childNode) | ||
{ | ||
$result = []; | ||
$moduleName = $childNode->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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> | ||
<xs:element name="view"> | ||
<xs:complexType> | ||
<xs:choice maxOccurs="unbounded"> | ||
<xs:element name="images" minOccurs="0" type="imagesType"/> | ||
</xs:choice> | ||
</xs:complexType> | ||
</xs:element> | ||
<xs:complexType name="imagesType"> | ||
<xs:sequence> | ||
<xs:element name="image" maxOccurs="unbounded"> | ||
<xs:complexType> | ||
<xs:sequence> | ||
<xs:element name="width" type="xs:positiveInteger" minOccurs="0"/> | ||
<xs:element name="height" type="xs:positiveInteger" minOccurs="0"/> | ||
<xs:element name="constrain" type="xs:boolean" minOccurs="0"/> | ||
<xs:element name="aspect_ratio" type="xs:boolean" minOccurs="0"/> | ||
<xs:element name="frame" type="xs:boolean" minOccurs="0"/> | ||
<xs:element name="transparency" type="xs:boolean" minOccurs="0"/> | ||
<xs:element name="background" minOccurs="0"> | ||
<xs:simpleType> | ||
<xs:restriction base="xs:string"> | ||
<xs:pattern value="\[(\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\]"/> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
</xs:element> | ||
</xs:sequence> | ||
<xs:attribute name="id" type="xs:string" use="required"/> | ||
<xs:attribute name="type" use="required"> | ||
<xs:simpleType> | ||
<xs:restriction base="xs:string"> | ||
<xs:enumeration value="thumbnail"/> | ||
<xs:enumeration value="small_image"/> | ||
<xs:enumeration value="image"/> | ||
<xs:enumeration value="swatch_image"/> | ||
<xs:enumeration value="swatch_thumb"/> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
</xs:attribute> | ||
</xs:complexType> | ||
</xs:element> | ||
</xs:sequence> | ||
<xs:attribute name="module" type="xs:string" use="required"/> | ||
</xs:complexType> | ||
</xs:schema> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.