Files
wyczarujprezent.pl/modules/inpostizi/upgrade/FileRemoverTrait.php
Jacek Pyziak 4066f6fa31 Add InPost Pay integration to admin templates
- Created a new template for the cart rule form with custom label, switch, and choice widgets.
- Implemented the InPost Pay block in the order details template for displaying delivery method, APM, and VAT invoice request.
- Added legacy support for the order details template to maintain compatibility with older PrestaShop versions.
2025-09-14 14:38:09 +02:00

55 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
namespace InPost\Izi\Upgrade;
use Symfony\Component\Filesystem\Filesystem;
/**
* @internal
*/
trait FileRemoverTrait
{
private static $namespacePrefix = 'izi\\prestashop\\';
/**
* @var \Module
*/
private $module;
/**
* @var Filesystem
*/
private $filesystem;
private function removeFiles(array $paths): bool
{
$basePath = rtrim($this->module->getLocalPath(), '/');
$files = array_map(static function (string $path) use ($basePath): string {
return sprintf('%s/%s', $basePath, $path);
}, $paths);
$this->getFileSystem()->remove($files);
return true;
}
private function removeClasses(array $classes): bool
{
$paths = array_map(static function (string $class): string {
$class = str_replace(self::$namespacePrefix, '', $class);
return 'src/' . str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';
}, $classes);
return $this->removeFiles($paths);
}
private function getFileSystem(): Filesystem
{
return $this->filesystem ?? $this->filesystem = new Filesystem();
}
}