Skip to content

Commit

Permalink
Merged PR 42072: Update Chat Profile controller to use correct interf…
Browse files Browse the repository at this point in the history
…aces

## What's being changed

We have removed a redundant class `Dotdigitalgroup\Chat\Model\EmailFlagManager`, and we have updated the `Dotdigitalgroup\Chat\Controller\Profile\Index` class to follow Magento best practices.

## Why it's being changed

This resolves some critical issues reported by the Magento upgrade compatibility tool.

## How to review / test this change

1. Enable chat
2. Test chat messaging works as expected.
3. Run DI compile insure there are no missing dependencies within any of the Dotdigital Modules

## Notes
The Flag Manager class was used in the very early days of the Chat codebase, when Chat was provided in the Email module. It provided a way of saving temporary config data during the trial setup. At the time we had to include it in our module in order to support Magento version 2.2 and lower (it was added to Magento in 2.3). However we stopped using it, and in fact it should never have even made it to v1.0.0 of the separate Chat module.

Related work items: #193594, #193596
  • Loading branch information
pvpcookie committed Jan 16, 2023
1 parent 64d48f2 commit 28981ff
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 243 deletions.
33 changes: 21 additions & 12 deletions Controller/Profile/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,27 @@

use Dotdigitalgroup\Chat\Model\Profile\UpdateChatProfile;
use Magento\Framework\App\Action\Context;
use Magento\Framework\App\ResponseInterface;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Framework\HTTP\PhpEnvironment\Response;

class Index extends Action
class Index implements HttpPostActionInterface
{
/**
* @var UpdateChatProfile
*/
private $chatProfile;

/**
* @var Response
*/
private $response;

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

/**
* Profile constructor
*
Expand All @@ -25,21 +36,19 @@ public function __construct(
UpdateChatProfile $chatProfile
) {
$this->chatProfile = $chatProfile;
parent::__construct($context);
$this->request = $context->getRequest();
$this->response = $context->getResponse();
}

/**
* Update the user's profile with Chat
*
* @return ResponseInterface
* @return Response
*/
public function execute()
public function execute(): Response
{
$this->chatProfile->update($this->getRequest()->getParam('profileId'));
/** @var \Magento\Framework\HTTP\PhpEnvironment\Response $response */
$response = $this->getResponse();
$response->setHttpResponseCode(204);
$response->sendHeaders();
return $response;
$this->chatProfile->update($this->request->getParam('profileId'));
$this->response->setHttpResponseCode(204);
return $this->response;
}
}
98 changes: 0 additions & 98 deletions Model/EmailFlagManager.php

This file was deleted.

133 changes: 0 additions & 133 deletions Test/Unit/Model/FlagManagerTest.php

This file was deleted.

0 comments on commit 28981ff

Please sign in to comment.