Skip to content

Commit aaf0bf2

Browse files
committed
ACP2E-3324: allow cli config set with and w/o lock for design theme configs and bypass saving design config that is locked
1 parent 2124104 commit aaf0bf2

File tree

4 files changed

+34
-159
lines changed

4 files changed

+34
-159
lines changed

app/code/Magento/Theme/Plugin/DesignPathValidatorPlugin.php renamed to app/code/Magento/Theme/Model/Config/PathValidator.php

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@
55
*/
66
declare(strict_types=1);
77

8-
namespace Magento\Theme\Plugin;
8+
namespace Magento\Theme\Model\Config;
99

10-
use Magento\Config\Model\Config\PathValidator;
1110
use Magento\Config\Model\Config\Structure;
12-
use Magento\Config\Model\Config\Structure\Element\Field;
1311
use Magento\Framework\Exception\ValidatorException;
1412
use Magento\Theme\Model\DesignConfigRepository;
1513

16-
class DesignPathValidatorPlugin
14+
class PathValidator extends \Magento\Config\Model\Config\PathValidator
1715
{
1816
/**
1917
* @param Structure $structure
@@ -23,35 +21,19 @@ public function __construct(
2321
private readonly Structure $structure,
2422
private readonly DesignConfigRepository $designConfigRepository
2523
) {
24+
parent::__construct($structure);
2625
}
2726

2827
/**
29-
* Allow setting design configuration from cli
30-
*
31-
* @param PathValidator $subject
32-
* @param callable $proceed
33-
* @param string $path
34-
* @return true
35-
* @throws ValidatorException
36-
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
28+
* @inheritdoc
3729
*/
38-
public function aroundValidate(PathValidator $subject, callable $proceed, $path): bool
30+
public function validate($path)
3931
{
4032
if (stripos($path, 'design/') !== 0) {
41-
return $proceed($path);
42-
}
43-
44-
$element = $this->structure->getElementByConfigPath($path);
45-
if ($element instanceof Field && $element->getConfigPath()) {
46-
$path = $element->getConfigPath();
33+
return parent::validate($path);
4734
}
4835

49-
$allPaths = array_merge($this->structure->getFieldPaths(), $this->getDesignFieldPaths());
50-
51-
if (!array_key_exists($path, $allPaths)) {
52-
throw new ValidatorException(__('The "%1" path doesn\'t exist. Verify and try again.', $path));
53-
}
54-
return true;
36+
return $this->validateDesignPath($path);
5537
}
5638

5739
/**
@@ -69,4 +51,26 @@ private function getDesignFieldPaths(): array
6951
}
7052
return $data;
7153
}
54+
55+
/**
56+
* Validate design path configurations
57+
*
58+
* @param string $path
59+
* @return bool
60+
* @throws ValidatorException
61+
*/
62+
private function validateDesignPath(string $path): bool
63+
{
64+
$element = $this->structure->getElementByConfigPath($path);
65+
if ($element instanceof Structure\Element\Field && $element->getConfigPath()) {
66+
$path = $element->getConfigPath();
67+
}
68+
69+
$allPaths = array_merge($this->structure->getFieldPaths(), $this->getDesignFieldPaths());
70+
71+
if (!array_key_exists($path, $allPaths)) {
72+
throw new ValidatorException(__('The "%1" path doesn\'t exist. Verify and try again.', $path));
73+
}
74+
return true;
75+
}
7276
}

app/code/Magento/Theme/Test/Unit/Plugin/DesignPathValidatorPluginTest.php

Lines changed: 0 additions & 130 deletions
This file was deleted.

app/code/Magento/Theme/etc/adminhtml/di.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,4 @@
4141
</argument>
4242
</arguments>
4343
</type>
44-
<type name="Magento\Config\Model\Config\PathValidator">
45-
<plugin name="validate_design_paths_plugin" type="Magento\Theme\Plugin\DesignPathValidatorPlugin"/>
46-
</type>
4744
</config>

app/code/Magento/Theme/etc/di.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,5 +334,9 @@
334334
<type name="Magento\Config\Console\Command\LocaleEmulator">
335335
<plugin name="themeForLocaleEmulator" type="Magento\Theme\Plugin\LocaleEmulator"/>
336336
</type>
337-
337+
<type name="Magento\Config\Console\Command\ConfigSet\ProcessorFacade">
338+
<arguments>
339+
<argument name="pathValidator" xsi:type="object">Magento\Theme\Model\Config\PathValidator</argument>
340+
</arguments>
341+
</type>
338342
</config>

0 commit comments

Comments
 (0)