2020-09-01 10:02:47 +03:00
|
|
|
<?php
|
2020-09-01 10:12:54 +03:00
|
|
|
/**
|
|
|
|
* The services of the session module.
|
|
|
|
*
|
2020-09-11 14:11:10 +03:00
|
|
|
* @package WooCommerce\PayPalCommerce\Session
|
2020-09-01 10:12:54 +03:00
|
|
|
*/
|
|
|
|
|
2020-09-01 10:02:47 +03:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-09-11 14:11:10 +03:00
|
|
|
namespace WooCommerce\PayPalCommerce\Session;
|
2020-09-01 10:02:47 +03:00
|
|
|
|
2020-09-11 14:11:10 +03:00
|
|
|
use WooCommerce\PayPalCommerce\Session\Cancellation\CancelController;
|
|
|
|
use WooCommerce\PayPalCommerce\Session\Cancellation\CancelView;
|
2020-09-01 10:02:47 +03:00
|
|
|
|
2020-09-01 10:12:54 +03:00
|
|
|
return array(
|
2020-09-11 13:38:02 +03:00
|
|
|
'session.handler' => function ( $container ) : SessionHandler {
|
2020-09-01 10:02:47 +03:00
|
|
|
|
2020-09-01 10:12:54 +03:00
|
|
|
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;
|
|
|
|
},
|
2020-09-11 13:38:02 +03:00
|
|
|
'session.cancellation.view' => function ( $container ) : CancelView {
|
2020-09-01 10:12:54 +03:00
|
|
|
return new CancelView();
|
|
|
|
},
|
2020-09-11 13:38:02 +03:00
|
|
|
'session.cancellation.controller' => function ( $container ) : CancelController {
|
2020-09-01 10:12:54 +03:00
|
|
|
return new CancelController(
|
|
|
|
$container->get( 'session.handler' ),
|
|
|
|
$container->get( 'session.cancellation.view' )
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|