Skip to content

Commit 1aad678

Browse files
committed
Major cleanup
1 parent 8431b23 commit 1aad678

File tree

10 files changed

+92
-126
lines changed

10 files changed

+92
-126
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [0.1.2] - 2021-05-13
10+
### Fixed
11+
- Fix new path validator by using "hack files"
12+
913
## [0.1.1] - 2020-07-29
1014
### Fixed
1115
- Fixed 2.4 compatibility

Console/Command/CopyHacks.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Yireo\DevHacks\Console\Command;
4+
5+
use Symfony\Component\Console\Command\Command;
6+
use Symfony\Component\Console\Input\InputArgument;
7+
use Symfony\Component\Console\Input\InputInterface;
8+
use Symfony\Component\Console\Output\OutputInterface;
9+
10+
class CopyHacks extends Command
11+
{
12+
protected function configure()
13+
{
14+
$this->setName('yireo_devhacks:copy_hacks')
15+
->setDescription('Copy some hacks');
16+
}
17+
18+
protected function execute(InputInterface $input, OutputInterface $output)
19+
{
20+
$copyDir = dirname(__DIR__) . '/../Copy';
21+
$copies = [
22+
\Magento\Framework\Filesystem\Directory\PathValidator::class => 'PathValidator.php'
23+
];
24+
25+
foreach ($copies as $className => $copyFile) {
26+
$originalFile = (new \ReflectionClass($className))->getFileName();
27+
if (!file_exists($originalFile)) {
28+
$output->writeln('<error>Original file does not exist: ' . $originalFile . '</error>');
29+
continue;
30+
}
31+
32+
$copyFile = $copyDir . '/' . $copyFile;
33+
if (!file_exists($copyFile)) {
34+
$output->writeln('<error>Hack file does not exist: ' . $copyFile . '</error>');
35+
continue;
36+
}
37+
38+
copy($copyFile, $originalFile);
39+
}
40+
}
41+
}

Console/Command/IntegrationTesting/PhpUnitFile/ToggleTestsCleanup.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
<?php
2-
3-
declare(strict_types=1);
1+
<?php declare(strict_types=1);
42

53
namespace Yireo\DevHacks\Console\Command\IntegrationTesting\PhpUnitFile;
64

Copy/PathValidator.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Magento\Framework\Filesystem\Directory;
4+
5+
use Magento\Framework\Filesystem\DriverInterface;
6+
7+
/**
8+
* @inheritDoc
9+
*
10+
* Validates paths using driver.
11+
*/
12+
class PathValidator implements PathValidatorInterface
13+
{
14+
/**
15+
* @param DriverInterface $driver
16+
*/
17+
public function __construct(DriverInterface $driver)
18+
{
19+
}
20+
21+
/**
22+
* @inheritDoc
23+
*/
24+
public function validate(
25+
string $directoryPath,
26+
string $path,
27+
?string $scheme = null,
28+
bool $absolutePath = false
29+
): void {}
30+
}

Override/DirectoryReadFactoryWithPathFixed.php

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

Override/DirectoryReadWithPathFixed.php

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

Override/TemplateFileValidator.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Yireo\DevHacks\Override;
4+
5+
use Magento\Framework\View\Element\Template\File\Validator;
6+
7+
class TemplateFileValidator extends Validator
8+
{
9+
public function isValid($filename)
10+
{
11+
return true;
12+
}
13+
}

Plugin/FileValidator.php

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

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "yireo/magento2-devhacks",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"license": "OSL-3.0",
55
"type": "magento2-module",
66
"homepage": "https://github.com/yireo/Yireo_DevHacks",

etc/di.xml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
<?xml version="1.0"?>
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
3-
<preference for="Magento\Framework\Filesystem\Directory\ReadFactory" type="Yireo\DevHacks\Override\DirectoryReadFactoryWithPathFixed"/>
4-
5-
<preference for="Magento\Framework\Filesystem\Directory\ReadInterface" type="Yireo\DevHacks\Override\DirectoryReadWithPathFixed"/>
6-
7-
<type name="Magento\Framework\View\Element\Template\File\Validator">
8-
<plugin name="templatesymlink_view_element_template_file_validator" type="Yireo\DevHacks\Plugin\FileValidator" sortOrder="10" disabled="false"/>
9-
</type>
3+
<preference for="Magento\Framework\View\Element\Template\File\Validator" type="Yireo\DevHacks\Override\TemplateFileValidator"/>
104

115
<type name="Magento\Framework\Console\CommandList">
126
<arguments>
137
<argument name="commands" xsi:type="array">
148
<item name="yireo_devhacks_integrationtesting_phpunit_toggletestscleanup" xsi:type="object">Yireo\DevHacks\Console\Command\IntegrationTesting\PhpUnitFile\ToggleTestsCleanup</item>
9+
<item name="yireo_devhacks_copy_hacks" xsi:type="object">Yireo\DevHacks\Console\Command\CopyHacks</item>
1510
</argument>
1611
</arguments>
1712
</type>

0 commit comments

Comments
 (0)