init
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace Esun\CustomerMessage\Controller\Account;
|
||||
|
||||
use Esun\CustomerMessage\Model\MessageProvider;
|
||||
use Magento\Customer\Controller\AbstractAccount;
|
||||
use Magento\Customer\Model\Session;
|
||||
use Magento\Framework\App\Action\HttpPostActionInterface;
|
||||
use Magento\Framework\App\Action\Context;
|
||||
use Magento\Framework\App\RequestInterface;
|
||||
use Magento\Framework\Controller\Result\RedirectFactory;
|
||||
use Magento\Framework\Data\Form\FormKey\Validator;
|
||||
|
||||
class Read extends AbstractAccount implements HttpPostActionInterface
|
||||
{
|
||||
public function __construct(
|
||||
Context $context,
|
||||
private readonly RequestInterface $request,
|
||||
private readonly RedirectFactory $redirects,
|
||||
private readonly Validator $formKey,
|
||||
private readonly Session $session,
|
||||
private readonly MessageProvider $provider
|
||||
) {
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
if ($this->formKey->validate($this->request)) {
|
||||
$this->provider->markRead(
|
||||
(int)$this->request->getParam('recipient_id'),
|
||||
(int)$this->session->getCustomerId()
|
||||
);
|
||||
}
|
||||
return $this->redirects->create()->setPath('customer-message/account/index');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user