-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mediator.php
52 lines (46 loc) · 1.52 KB
/
Mediator.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/**
* @author Artemii Karkusha
* @copyright Copyright (c) (https://www.linkedin.com/in/artemiy-karkusha/)
*/
declare(strict_types=1);
namespace ArtemiiKarkusha\DesignPatterns\Controller\Test;
use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Framework\Controller\ResultFactory;
use ArtemiiKarkusha\DesignPatterns\Api\Mediator\ConciergeServiceInterface;
use Magento\Framework\Controller\ResultInterface;
use Magento\Framework\Exception\NotFoundException;
class Mediator implements HttpGetActionInterface
{
/**
* @param ResultFactory $resultFactory
* @param ConciergeServiceInterface $conciergeService
*/
public function __construct(
private ResultFactory $resultFactory,
private ConciergeServiceInterface $conciergeService
) {
}
/**
* @inheritDoc
*/
public function execute(): ResultInterface
{
$this->getContents();
return $this->resultFactory->create(ResultFactory::TYPE_RAW);
}
/**
* @return void
*/
public function getContents(): void
{
try {
$this->conciergeService->executeRequestByName('CallATaxi');
$this->conciergeService->executeRequestByName('CallAMaster');
$this->conciergeService->executeRequestByName('DeliveryAFlower');
$this->conciergeService->executeRequestByName('DeliveryAFlowerBluBluBlu');
} catch (NotFoundException $notFoundException) {
echo sprintf('%s<br>', $notFoundException->getMessage());
}
}
}