Skip to content

Commit

Permalink
fis session
Browse files Browse the repository at this point in the history
  • Loading branch information
alnv committed Feb 15, 2021
1 parent f89ab0d commit 12aef8b
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions WishlistModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 = [];
Expand Down Expand Up @@ -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 ) ) {
Expand Down Expand Up @@ -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'] ];
Expand All @@ -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 ) ) {
Expand Down Expand Up @@ -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 ) ) {
Expand Down

0 comments on commit 12aef8b

Please sign in to comment.