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:
43
modules/inpostizi/src/Http/Util/UriResolver.php
Normal file
43
modules/inpostizi/src/Http/Util/UriResolver.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\Http\Util;
|
||||
|
||||
final class UriResolver
|
||||
{
|
||||
public static function resolve(string $uri, string $baseUri): string
|
||||
{
|
||||
$uriParts = parse_url($uri);
|
||||
|
||||
if (!empty($uriParts['host'])) {
|
||||
return $uri;
|
||||
}
|
||||
|
||||
$baseUriParts = parse_url($baseUri);
|
||||
$uriParts['path'] = self::resolvePath($baseUriParts, $uriParts);
|
||||
$uriParts += $baseUriParts;
|
||||
|
||||
return http_build_url($uriParts);
|
||||
}
|
||||
|
||||
private static function resolvePath(array $baseUri, array $uri): string
|
||||
{
|
||||
$basePath = $baseUri['path'] ?? null;
|
||||
$path = $uri['path'] ?? null;
|
||||
|
||||
if (null === $path) {
|
||||
$path = $basePath;
|
||||
} elseif ('/' !== $path[0]) {
|
||||
if (null === $basePath) {
|
||||
$path = '/' . $path;
|
||||
} else {
|
||||
$segments = explode('/', $basePath);
|
||||
array_splice($segments, -1, 1, [$path]);
|
||||
$path = implode('/', $segments);
|
||||
}
|
||||
}
|
||||
|
||||
return empty($path) ? '/' : $path;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user