Skip to content

Commit

Permalink
Release/3.8.6 (#236)
Browse files Browse the repository at this point in the history
* TSD-325: Missing Product Attributes in Config; Use AttributeRepository

* Update turnToConfig versions; replace helper with model; bump module version

* SSO Redirect cleanup; remove unnecessary di; move SSO config to model
  • Loading branch information
ptrollinspt authored Jun 18, 2024
1 parent 68ceac3 commit ea57942
Show file tree
Hide file tree
Showing 8 changed files with 329 additions and 285 deletions.
12 changes: 6 additions & 6 deletions Block/TurnToConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Magento\Framework\View\Element\Template\Context;
use TurnTo\SocialCommerce\Api\TurnToConfigDataSourceInterface;
use TurnTo\SocialCommerce\Helper\Config as TurnToConfigHelper;
use TurnTo\SocialCommerce\Helper\Version;
use TurnTo\SocialCommerce\Model\Version;

/**
* @method void setConfigData(TurnToConfigDataSourceInterface|array $config)
Expand All @@ -38,7 +38,7 @@ class TurnToConfig extends Template implements TurnToConfigInterface
/**
* @var Version
*/
protected $versionHelper;
protected $version;
/**
* @var Json
*/
Expand All @@ -49,7 +49,7 @@ class TurnToConfig extends Template implements TurnToConfigInterface
* @param TurnToConfigHelper $configHelper
* @param ResolverInterface $localeResolver
* @param Data $helper
* @param Version $versionHelper
* @param Version $version
* @param Json $json
* @param array $data
*/
Expand All @@ -58,7 +58,7 @@ public function __construct(
TurnToConfigHelper $configHelper,
ResolverInterface $localeResolver,
Data $helper,
Version $versionHelper,
Version $version,
Json $json,
array $data = []
) {
Expand All @@ -71,7 +71,7 @@ public function __construct(
$this->configHelper = $configHelper;
$this->localeResolver = $localeResolver;
$this->helper = $helper;
$this->versionHelper = $versionHelper;
$this->version = $version;
$this->json = $json;
}

Expand All @@ -91,7 +91,7 @@ public function getJavaScriptConfig()
$additionalConfigData['baseUrl'] = $this->_storeManager->getStore()->getBaseUrl();
$additionalConfigData['siteKey' ] = $this->configHelper->getSiteKey();
$additionalConfigData = ['locale' => $this->localeResolver->getLocale()];
$additionalConfigData['extensionVersion'] = ['magentoVersion'=> $this->versionHelper->getMagentoVersion(), 'turnToCart' => $this->versionHelper->getTurnToVersion()];
$additionalConfigData['extensionVersion'] = ['magentoVersion'=> $this->version->getMagentoVersion(), 'turnToCart' => $this->version->getModuleVersion()];
$additionalConfigData['baseUrl'] = $this->_storeManager->getStore()->getBaseUrl();
$additionalConfigData['sso'] = ['userDataFn' => null];

Expand Down
88 changes: 41 additions & 47 deletions Controller/SSO/RedirectToLogin.php
Original file line number Diff line number Diff line change
@@ -1,93 +1,87 @@
<?php
/**
* @category ClassyLlama
* @package
* @copyright Copyright (c) 2019 Classy Llama Studios, LLC
* Copyright © Pixlee TurnTo, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace TurnTo\SocialCommerce\Controller\SSO;


use Magento\Customer\Model\SessionFactory;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use TurnTo\SocialCommerce\Helper\Config;
use TurnTo\SocialCommerce\Model\Config\Sso;

class RedirectToLogin extends \Magento\Framework\App\Action\Action
class RedirectToLogin extends Action
{


/**
* @var Magento\Framework\UrlInterface
*/
private $uriInterface;
/**
* @var Config
* @var SessionFactory
*/
private $config;
protected $customerSessionFactory;
/**
* @var \Magento\Framework\Registry
* @var Sso
*/
private $registry;
protected $ssoConfig;

/**
* @var \Magento\Customer\Model\SessionFactory
* @param Context $context
* @param Sso $ssoConfig
* @param SessionFactory $customerSessionFactory
*/
private $customerSessionFactory;


public function __construct(Context $context,
\Magento\Framework\Message\ManagerInterface $messageManager,
\Magento\Framework\UrlInterface $uriInterface,
Config $config,
\Magento\Customer\Model\SessionFactory $customerSessionFactory
)
{
$this->messageManager = $messageManager;
$this->uriInterface = $uriInterface;
$this->config = $config;
$this->customerSessionFactory = $customerSessionFactory;
public function __construct(
Context $context,
SessionFactory $customerSessionFactory,
Sso $ssoConfig,
) {
parent::__construct($context);
$this->customerSessionFactory = $customerSessionFactory;
$this->ssoConfig = $ssoConfig;
}

public function execute()
{
$url = $this->_redirect->getRefererUrl();

$login_url = $this->_url->getUrl(
'customer/account/login',
['referer' => base64_encode($url)]
);
$resultRedirect = $this->resultRedirectFactory->create();
$login_url = $this->uriInterface
->getUrl('customer/account/login',
['referer' => base64_encode($url)]
);
$resultRedirect->setPath($login_url);
$this->messageManager->addNoticeMessage($this->getMessage());
if (!empty($message = $this->getMessage())) {
$this->messageManager->addNoticeMessage($message);
}

//store the PDP in session
$customerSession = $this->customerSessionFactory->create();
$customerSession->setPdpUrl($url);

return $resultRedirect;
}

/**
* @return string
*/
public function getMessage()
{
$action = $this->getRequest()->getParam('action');
switch ($action) {
case "QUESTION_CREATE":
if($this->getRequest()->getParam('authSetting') == 'ANONYMOUS'){
return $this->config->getQuestionMsgAnon();
if($this->getRequest()->getParam('authSetting') === 'ANONYMOUS'){
return $this->ssoConfig->getQuestionMsgAnon();
}
return $this->config->getQuestionMsg();
return $this->ssoConfig->getQuestionMsg();
case "ANSWER_CREATE":
return $this->config->getAnswerMessage();
return $this->ssoConfig->getAnswerMessage();
case "REVIEW_CREATE":
if ($this->getRequest()->getParam('authSetting') == 'PURCHASE_REQUIRED') {
return $this->config->getReviewMsgPurchaseReq();
if ($this->getRequest()->getParam('authSetting') === 'PURCHASE_REQUIRED') {
return $this->ssoConfig->getReviewMsgPurchaseReq();
}
return $this->config->getReviewMsg();
return $this->ssoConfig->getReviewMsg();
case "REPLY_CREATE":
return $this->config->getReplyMsg();
return $this->ssoConfig->getReplyMsg();
default:
return "";
}

}

}

Loading

0 comments on commit ea57942

Please sign in to comment.