Skip to content

Commit

Permalink
Major cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jissereitsma committed May 13, 2021
1 parent 8431b23 commit 1aad678
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 126 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 41 additions & 0 deletions Console/Command/CopyHacks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php declare(strict_types=1);

namespace Yireo\DevHacks\Console\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class CopyHacks extends Command
{
protected function configure()
{
$this->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('<error>Original file does not exist: ' . $originalFile . '</error>');
continue;
}

$copyFile = $copyDir . '/' . $copyFile;
if (!file_exists($copyFile)) {
$output->writeln('<error>Hack file does not exist: ' . $copyFile . '</error>');
continue;
}

copy($copyFile, $originalFile);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?php

declare(strict_types=1);
<?php declare(strict_types=1);

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

Expand Down
30 changes: 30 additions & 0 deletions Copy/PathValidator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php declare(strict_types=1);

namespace Magento\Framework\Filesystem\Directory;

use Magento\Framework\Filesystem\DriverInterface;

/**
* @inheritDoc
*
* Validates paths using driver.
*/
class PathValidator implements PathValidatorInterface
{
/**
* @param DriverInterface $driver
*/
public function __construct(DriverInterface $driver)
{
}

/**
* @inheritDoc
*/
public function validate(
string $directoryPath,
string $path,
?string $scheme = null,
bool $absolutePath = false
): void {}
}
53 changes: 0 additions & 53 deletions Override/DirectoryReadFactoryWithPathFixed.php

This file was deleted.

12 changes: 0 additions & 12 deletions Override/DirectoryReadWithPathFixed.php

This file was deleted.

13 changes: 13 additions & 0 deletions Override/TemplateFileValidator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php declare(strict_types=1);

namespace Yireo\DevHacks\Override;

use Magento\Framework\View\Element\Template\File\Validator;

class TemplateFileValidator extends Validator
{
public function isValid($filename)
{
return true;
}
}
50 changes: 0 additions & 50 deletions Plugin/FileValidator.php

This file was deleted.

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
9 changes: 2 additions & 7 deletions etc/di.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Framework\Filesystem\Directory\ReadFactory" type="Yireo\DevHacks\Override\DirectoryReadFactoryWithPathFixed"/>

<preference for="Magento\Framework\Filesystem\Directory\ReadInterface" type="Yireo\DevHacks\Override\DirectoryReadWithPathFixed"/>

<type name="Magento\Framework\View\Element\Template\File\Validator">
<plugin name="templatesymlink_view_element_template_file_validator" type="Yireo\DevHacks\Plugin\FileValidator" sortOrder="10" disabled="false"/>
</type>
<preference for="Magento\Framework\View\Element\Template\File\Validator" type="Yireo\DevHacks\Override\TemplateFileValidator"/>

<type name="Magento\Framework\Console\CommandList">
<arguments>
<argument name="commands" xsi:type="array">
<item name="yireo_devhacks_integrationtesting_phpunit_toggletestscleanup" xsi:type="object">Yireo\DevHacks\Console\Command\IntegrationTesting\PhpUnitFile\ToggleTestsCleanup</item>
<item name="yireo_devhacks_copy_hacks" xsi:type="object">Yireo\DevHacks\Console\Command\CopyHacks</item>
</argument>
</arguments>
</type>
Expand Down

0 comments on commit 1aad678

Please sign in to comment.