woocommerce-paypal-payments/modules/ppcp-session/services.php
2020-09-11 13:38:02 +03:00

39 lines
1.1 KiB
PHP

<?php
/**
* The services of the session module.
*
* @package Inpsyde\PayPalCommerce\Session
*/
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 array(
'session.handler' => function ( $container ) : SessionHandler {
if ( is_null( WC()->session ) ) {
return new SessionHandler();
}
$result = WC()->session->get( SessionHandler::ID );
if ( is_a( $result, SessionHandler::class ) ) {
return $result;
}
$session_handler = new SessionHandler();
WC()->session->set( SessionHandler::ID, $session_handler );
return $session_handler;
},
'session.cancellation.view' => function ( $container ) : CancelView {
return new CancelView();
},
'session.cancellation.controller' => function ( $container ) : CancelController {
return new CancelController(
$container->get( 'session.handler' ),
$container->get( 'session.cancellation.view' )
);
},
);