Skip to content

Commit

Permalink
Fix layout file detected in wrong area scope
Browse files Browse the repository at this point in the history
An adminhtml xml file is detected as being overridden in a frontend theme

fix issue #2
  • Loading branch information
convenient committed Dec 7, 2018
1 parent b376bdb commit c631006
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0"?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">

</page>
1 change: 1 addition & 0 deletions dev/output/expected/magento21.out.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@
| Core file | Override/extended (layout xml) |
+------------------------------------------------------------------------+--------------------------------------------------------------------------------+
| vendor/magento/module-sales/view/frontend/layout/sales_order_print.xml | app/design/frontend/Ampersand/theme/Magento_Sales/layout/sales_order_print.xml |
| vendor/magento/module-sales/view/frontend/layout/sales_order_view.xml | app/design/frontend/Ampersand/theme/Magento_Sales/layout/sales_order_view.xml |
+------------------------------------------------------------------------+--------------------------------------------------------------------------------+
7 changes: 6 additions & 1 deletion src/Ampersand/PatchHelper/Helper/PatchOverrideValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,18 @@ public function validateWebTemplateHtml($file)
private function validateLayoutFile($file)
{
$parts = explode('/', $file);
$area = (str_contains($file, '/adminhtml/')) ? 'adminhtml' : 'frontend';
$module = $parts[2] . '_' . $parts[3];

$layoutFile = end($parts);

$potentialOverrides = array_filter($this->listOfXmlFiles, function ($potentialFilePath) use ($module, $layoutFile) {
$potentialOverrides = array_filter($this->listOfXmlFiles, function ($potentialFilePath) use ($module, $area, $layoutFile) {
$validFile = true;

if (!str_contains($potentialFilePath, $area)) {
// This is not in the same area
$validFile = false;
}
if (!str_ends_with($potentialFilePath, $layoutFile)) {
// This is not the same file name as our layout file
$validFile = false;
Expand Down

0 comments on commit c631006

Please sign in to comment.