From 1aad678c765cf9d4a4a22f85ce39baafb23fd4ef Mon Sep 17 00:00:00 2001 From: jisse Reitsma Date: Thu, 13 May 2021 11:33:07 +0200 Subject: [PATCH] Major cleanup --- CHANGELOG.md | 4 ++ Console/Command/CopyHacks.php | 41 ++++++++++++++ .../PhpUnitFile/ToggleTestsCleanup.php | 4 +- Copy/PathValidator.php | 30 +++++++++++ .../DirectoryReadFactoryWithPathFixed.php | 53 ------------------- Override/DirectoryReadWithPathFixed.php | 12 ----- Override/TemplateFileValidator.php | 13 +++++ Plugin/FileValidator.php | 50 ----------------- composer.json | 2 +- etc/di.xml | 9 +--- 10 files changed, 92 insertions(+), 126 deletions(-) create mode 100644 Console/Command/CopyHacks.php create mode 100644 Copy/PathValidator.php delete mode 100644 Override/DirectoryReadFactoryWithPathFixed.php delete mode 100644 Override/DirectoryReadWithPathFixed.php create mode 100644 Override/TemplateFileValidator.php delete mode 100644 Plugin/FileValidator.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 04f5382..6c39e86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.1.2] - 2021-05-13 +### Fixed +- Fix new path validator by using "hack files" + ## [0.1.1] - 2020-07-29 ### Fixed - Fixed 2.4 compatibility diff --git a/Console/Command/CopyHacks.php b/Console/Command/CopyHacks.php new file mode 100644 index 0000000..d5cae9a --- /dev/null +++ b/Console/Command/CopyHacks.php @@ -0,0 +1,41 @@ +setName('yireo_devhacks:copy_hacks') + ->setDescription('Copy some hacks'); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $copyDir = dirname(__DIR__) . '/../Copy'; + $copies = [ + \Magento\Framework\Filesystem\Directory\PathValidator::class => 'PathValidator.php' + ]; + + foreach ($copies as $className => $copyFile) { + $originalFile = (new \ReflectionClass($className))->getFileName(); + if (!file_exists($originalFile)) { + $output->writeln('Original file does not exist: ' . $originalFile . ''); + continue; + } + + $copyFile = $copyDir . '/' . $copyFile; + if (!file_exists($copyFile)) { + $output->writeln('Hack file does not exist: ' . $copyFile . ''); + continue; + } + + copy($copyFile, $originalFile); + } + } +} \ No newline at end of file diff --git a/Console/Command/IntegrationTesting/PhpUnitFile/ToggleTestsCleanup.php b/Console/Command/IntegrationTesting/PhpUnitFile/ToggleTestsCleanup.php index 82088b0..dbfabaf 100644 --- a/Console/Command/IntegrationTesting/PhpUnitFile/ToggleTestsCleanup.php +++ b/Console/Command/IntegrationTesting/PhpUnitFile/ToggleTestsCleanup.php @@ -1,6 +1,4 @@ -customDriverPool = $driverPool; - } - - /** - * @param string $path - * @param string $driverCode - * @return DirectoryReadInterface - */ - public function create($path, $driverCode = DriverPool::FILE) - { - $driver = $this->customDriverPool->getDriver($driverCode); - $factory = new FileReadFactory( - $this->customDriverPool - ); - - return new DirectoryReadWithPathFixed( - $factory, - $driver, - $path - ); - } -} diff --git a/Override/DirectoryReadWithPathFixed.php b/Override/DirectoryReadWithPathFixed.php deleted file mode 100644 index 6175f26..0000000 --- a/Override/DirectoryReadWithPathFixed.php +++ /dev/null @@ -1,12 +0,0 @@ -appState = $appState; - } - - /** - * Allow for any file as long as it exists to be used for a template - * - * @param object $subject - * @param callback $proceed - * @param string $filename - * @return bool - **/ - public function aroundIsValid($subject, $proceed, $filename) - { - if ($this->appState->getMode() !== AppState::MODE_DEVELOPER) { - return $proceed($filename); - } - - if ($filename == false || !is_file($filename)) { - return false; - } - - return $proceed($filename) || file_exists($filename); - } -} diff --git a/composer.json b/composer.json index f7c70ec..210eda7 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "yireo/magento2-devhacks", - "version": "0.1.1", + "version": "0.1.2", "license": "OSL-3.0", "type": "magento2-module", "homepage": "https://github.com/yireo/Yireo_DevHacks", diff --git a/etc/di.xml b/etc/di.xml index 8e77c56..45b2bd8 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -1,17 +1,12 @@ - - - - - - - + Yireo\DevHacks\Console\Command\IntegrationTesting\PhpUnitFile\ToggleTestsCleanup + Yireo\DevHacks\Console\Command\CopyHacks