diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..6dba519 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Mark van der Werf + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..f0ba072 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Layout + +Collection of layout updates to improve the layout features of Magento 2 \ No newline at end of file diff --git a/View/Layout/Reader/Block.php b/View/Layout/Reader/Block.php new file mode 100644 index 0000000..41575e1 --- /dev/null +++ b/View/Layout/Reader/Block.php @@ -0,0 +1,91 @@ +scopeConfig = $scopeConfig; + $this->scopeResolver = $scopeResolver; + } + + protected function scheduleReference( + Layout\ScheduledStructure $scheduledStructure, + Layout\Element $currentElement + ) { + $elementName = $currentElement->getAttribute('name'); + $elementRemove = filter_var($currentElement->getAttribute('remove'), FILTER_VALIDATE_BOOLEAN); + + if ($elementRemove) { + $configPath = (string)$currentElement->getAttribute(Layout\ConfigCondition::NAME); + + if (empty($configPath) || + $this->scopeConfig->isSetFlag($configPath, $this->scopeType, $this->scopeResolver->getScope())) { + $scheduledStructure->setElementToRemoveList($elementName); + return; + } + } elseif ($currentElement->getAttribute('remove')) { + $scheduledStructure->unsetElementFromListToRemove($elementName); + } + + $data = $scheduledStructure->getStructureElementData($elementName, []); + $data['attributes'] = $this->mergeBlockAttributes($data, $currentElement); + $this->updateScheduledData($currentElement, $data); + $this->evaluateArguments($currentElement, $data); + $scheduledStructure->setStructureElementData($elementName, $data); + } +} \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100755 index 0000000..940b657 --- /dev/null +++ b/composer.json @@ -0,0 +1,19 @@ +{ + "name": "gigadesign/module-magento2-layout", + "description": "Collection of layout fixes that can be used in modules", + "license": "proprietary", + "authors": [ + { + "name": "Mark van der Werf", + "email": "info@gigadesign.nl" + } + ], + "autoload": { + "files": [ + "registration.php" + ], + "psr-4": { + "Gigadesign\\Layout\\": "" + } + } +} \ No newline at end of file diff --git a/etc/di.xml b/etc/di.xml new file mode 100644 index 0000000..a7e8d0b --- /dev/null +++ b/etc/di.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/etc/module.xml b/etc/module.xml new file mode 100755 index 0000000..55e4669 --- /dev/null +++ b/etc/module.xml @@ -0,0 +1,5 @@ + + + + diff --git a/registration.php b/registration.php new file mode 100755 index 0000000..f729a84 --- /dev/null +++ b/registration.php @@ -0,0 +1,6 @@ +