From 12aef8bb5dbc645992eca9fd1334364d726aa3cb Mon Sep 17 00:00:00 2001 From: Alexander Naumov Date: Mon, 15 Feb 2021 08:20:06 +0100 Subject: [PATCH] fis session --- WishlistModule.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/WishlistModule.php b/WishlistModule.php index f44cf7e..e924b63 100644 --- a/WishlistModule.php +++ b/WishlistModule.php @@ -17,6 +17,14 @@ public function __construct() { $this->import( 'Database' ); } + protected function getSession() { + + if (version_compare('4.4', VERSION, '<=')) { + return \System::getContainer()->get('session'); + } + return \Session::getInstance(); + } + public function initialize( &$objCatalogView ) { $this->strTable = $objCatalogView->catalogTablename; @@ -35,7 +43,7 @@ public function initialize( &$objCatalogView ) { if ( !$this->validateInput() ) return null; - $objSession = \Session::getInstance(); + $objSession = $this->getSession(); $arrTables = $objSession->get('wishlist_tables'); if ( !is_array( $arrTables ) ) $arrTables = []; @@ -75,7 +83,7 @@ public function renderCatalog( &$arrCatalog, $strTablename, $objCatalogView ) { $strAmountValue = '1'; $blnInWishlist = false; - $objSession = \Session::getInstance(); + $objSession = $this->getSession(); $arrSession = $objSession->get( 'wishlist_' . $strTablename ); if ( !Toolkit::isEmpty( $arrSession ) ) { @@ -130,7 +138,7 @@ public function setQuery( $arrQuery, $objCatalogView ) { if ( !$objCatalogView->wishlistEnableFilter ) return $arrQuery; - $objSession = \Session::getInstance(); + $objSession = $this->getSession(); $arrSession = $objSession->get( 'wishlist_' . $objCatalogView->catalogTablename ); if ( Toolkit::isEmpty( $arrSession ) ) $arrSession = [ 'ids' => ['0'] ]; @@ -148,13 +156,13 @@ public function setQuery( $arrQuery, $objCatalogView ) { protected function addToWishlist() { - $objSession = \Session::getInstance(); + $objSession = $this->getSession(); $objSession->set( 'wishlist_' . $this->strTable, $this->getWishlistData() ); } protected function removeFromWishlist() { - $objSession = \Session::getInstance(); + $objSession = $this->getSession(); $arrSession = $objSession->get( 'wishlist_' . $this->strTable ); if ( !Toolkit::isEmpty( $arrSession ) ) { @@ -216,7 +224,7 @@ protected function getWishlistData() { $arrIds = []; $arrAmounts = []; - $objSession = \Session::getInstance(); + $objSession = $this->getSession(); $arrSession = $objSession->get( 'wishlist_' . $this->strTable ); if ( !Toolkit::isEmpty( $arrSession ) ) {