- Banners frontend: front\Views\Banners (new), BannerRepository +2 frontend methods, front\view\Site przepięty, usunięte front\factory\Banners i front\view\Banners - Cache cleanup: eliminacja legacy class.Cache.php (file-based cache), 13 metod front\factory przepiętych z \Cache::fetch/store na CacheHandler - Shared\Cache namespace: CacheHandler i RedisConnection przeniesione do Shared\Cache\, 60 odwołań CacheHandler i 12 odwołań RedisConnection przepiętych, usunięte backward-compat wrappery class.CacheHandler.php i class.RedisConnection.php - Naprawione rozbieżności kluczy cache (random_products, category_name) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
75 lines
2.0 KiB
PHP
75 lines
2.0 KiB
PHP
<?php
|
|
namespace front\factory;
|
|
|
|
class ShopPaymentMethod
|
|
{
|
|
private static function repo(): \Domain\PaymentMethod\PaymentMethodRepository
|
|
{
|
|
global $mdb;
|
|
return new \Domain\PaymentMethod\PaymentMethodRepository( $mdb );
|
|
}
|
|
|
|
// get_apilo_payment_method_id
|
|
static public function get_apilo_payment_method_id( $payment_method_id ) {
|
|
return self::repo()->getApiloPaymentTypeId( (int)$payment_method_id );
|
|
}
|
|
|
|
public static function payment_methods_by_transport( $transport_method_id )
|
|
{
|
|
$transport_method_id = (int)$transport_method_id;
|
|
$cacheHandler = new \Shared\Cache\CacheHandler();
|
|
$cacheKey = 'payment_methods_by_transport' . $transport_method_id;
|
|
$objectData = $cacheHandler->get( $cacheKey );
|
|
|
|
if ( $objectData ) {
|
|
return unserialize( $objectData );
|
|
}
|
|
|
|
$payments = self::repo()->forTransport( $transport_method_id );
|
|
$cacheHandler->set( $cacheKey, $payments );
|
|
|
|
return $payments;
|
|
}
|
|
|
|
public static function is_payment_active( $payment_method_id )
|
|
{
|
|
return self::repo()->isActive( (int)$payment_method_id );
|
|
}
|
|
|
|
public static function payment_method( $payment_method_id )
|
|
{
|
|
$payment_method_id = (int)$payment_method_id;
|
|
$cacheHandler = new \Shared\Cache\CacheHandler();
|
|
$cacheKey = 'payment_method' . $payment_method_id;
|
|
$objectData = $cacheHandler->get( $cacheKey );
|
|
|
|
if ( !$objectData )
|
|
{
|
|
$payment_method = self::repo()->findActiveById( $payment_method_id );
|
|
$cacheHandler->set( $cacheKey, $payment_method );
|
|
}
|
|
else
|
|
{
|
|
return unserialize( $objectData );
|
|
}
|
|
|
|
return $payment_method;
|
|
}
|
|
|
|
public static function payment_methods()
|
|
{
|
|
$cacheHandler = new \Shared\Cache\CacheHandler();
|
|
$cacheKey = 'payment_methods';
|
|
$objectData = $cacheHandler->get( $cacheKey );
|
|
|
|
if ( $objectData ) {
|
|
return unserialize( $objectData );
|
|
}
|
|
|
|
$payment_methods = self::repo()->allActive();
|
|
$cacheHandler->set( $cacheKey, $payment_methods );
|
|
|
|
return $payment_methods;
|
|
}
|
|
}
|