mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Without this REST API request on the admin side return 500 as the is_admin check is not enough
36 lines
1.2 KiB
PHP
36 lines
1.2 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace Inpsyde\PayPalCommerce\Session;
|
|
|
|
use Dhii\Data\Container\ContainerInterface;
|
|
use Inpsyde\PayPalCommerce\Session\Cancellation\CancelController;
|
|
use Inpsyde\PayPalCommerce\Session\Cancellation\CancelView;
|
|
|
|
return [
|
|
'session.handler' => function (ContainerInterface $container) : SessionHandler {
|
|
|
|
if (is_admin()) {
|
|
return new SessionHandler();
|
|
}
|
|
if (is_null(WC()->session)) {
|
|
return new SessionHandler();
|
|
}
|
|
$result = WC()->session->get(SessionHandler::ID);
|
|
if (is_a($result, SessionHandler::class)) {
|
|
return $result;
|
|
}
|
|
$sessionHandler = new SessionHandler();
|
|
WC()->session->set(SessionHandler::ID, $sessionHandler);
|
|
return $sessionHandler;
|
|
},
|
|
'session.cancellation.view' => function (ContainerInterface $container) : CancelView {
|
|
return new CancelView();
|
|
},
|
|
'session.cancellation.controller' => function (ContainerInterface $container) : CancelController {
|
|
return new CancelController(
|
|
$container->get('session.handler'),
|
|
$container->get('session.cancellation.view')
|
|
);
|
|
},
|
|
];
|