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.
This commit is contained in:
54
modules/inpostizi/upgrade/FileRemoverTrait.php
Normal file
54
modules/inpostizi/upgrade/FileRemoverTrait.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user