Skip to content

Commit

Permalink
Merge branch 'develop' into release/1.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sta1r committed Oct 6, 2023
2 parents f25f840 + c6205a9 commit ce29605
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Controller/Adminhtml/Studio/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Index extends Action
/**
* @var PageFactory
*/
protected $resultPageFactory;
private $resultPageFactory;

/**
* @var Data
Expand Down
20 changes: 17 additions & 3 deletions Plugin/EmailcapturePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
use Dotdigitalgroup\Chat\Model\Config;
use Dotdigitalgroup\Chat\Model\Profile\UpdateChatProfile;
use Dotdigitalgroup\Email\Controller\Ajax\Emailcapture;
use Magento\Framework\App\Action\Context;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Controller\ResultInterface;
use Magento\Framework\Stdlib\Cookie\CookieReaderInterface;

class EmailcapturePlugin
Expand All @@ -14,6 +17,11 @@ class EmailcapturePlugin
*/
private $chatProfile;

/**
* @var RequestInterface
*/
private $request;

/**
* @var CookieReaderInterface
*/
Expand All @@ -24,25 +32,31 @@ class EmailcapturePlugin
*
* @param UpdateChatProfile $chatProfile
* @param CookieReaderInterface $cookieReader
* @param Context $context
*/
public function __construct(
UpdateChatProfile $chatProfile,
CookieReaderInterface $cookieReader
CookieReaderInterface $cookieReader,
Context $context
) {
$this->chatProfile = $chatProfile;
$this->cookieReader = $cookieReader;
$this->request = $context->getRequest();
}

/**
* After email capture execute
*
* @param Emailcapture $emailcapture
* @param ResultInterface $result
*/
public function afterExecute(Emailcapture $emailcapture)
public function afterExecute(Emailcapture $emailcapture, $result)
{
// if a chat profile ID is present, update chat profile data
if ($chatProfileId = $this->cookieReader->getCookie(Config::COOKIE_CHAT_PROFILE, null)) {
$this->chatProfile->update($chatProfileId, $emailcapture->getRequest()->getParam('email'));
$this->chatProfile->update($chatProfileId, $this->request->getParam('email'));
}

return $result;
}
}
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](LICENSE.md)

## Requirements
- This module requires the `Dotdigitalgroup_Email` module v4.18.0+
- This module requires the `Dotdigitalgroup_Email` module v4.23.0+

## Activation
- This module is included in our core extension. Please refer to [these instructions](https://github.com/dotmailer/dotmailer-magento2-extension#installation) to install via the Magento Marketplace.
Expand All @@ -12,6 +12,12 @@

## Changelog

### 1.9.0

##### Improvements
- We refactored a controller plugin to replace usage of `$this→getRequest()`.
- We've removed avoidable usages of protected access for properties and methods.

### 1.8.0

##### What's new
Expand Down
3 changes: 2 additions & 1 deletion Test/Integration/Controller/Ajax/EmailcaptureUpdateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Dotdigitalgroup\Chat\Model\Config;
use Dotdigitalgroup\Chat\Model\Profile\UpdateChatProfile;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\App\Request\Http as HttpRequest;
use Magento\TestFramework\TestCase\AbstractController;

class EmailcaptureUpdateTest extends AbstractController
Expand Down Expand Up @@ -32,7 +33,7 @@ public function testUpdateChatProfileCookie()
->method('update')
->with($profileId, $email);

$this->getRequest()->setParam('email', $email);
$this->getRequest()->setParam('email', $email)->setMethod(HttpRequest::METHOD_POST);

$this->dispatch('/connector/ajax/emailcapture');
}
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "dotdigital/dotdigital-magento2-extension-chat",
"description": "Dotdigital for Magento 2: Chat module",
"type": "magento2-module",
"version": "1.8.0",
"version": "1.9.0",
"license": "MIT",
"repositories": [
{
Expand All @@ -15,7 +15,7 @@
},
"require": {
"php": "^7.4||^8.0",
"dotdigital/dotdigital-magento2-extension": "^4.18.0",
"dotdigital/dotdigital-magento2-extension": "^4.23.0",
"magento/framework": ">=102 <104",
"magento/module-config": ">=101 <102",
"magento/module-backend": ">=101 <103",
Expand Down

0 comments on commit ce29605

Please sign in to comment.