Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
All Data Structures Namespaces Files Functions Variables Pages
NotifyDataChangedCommand.php
Go to the documentation of this file.
1 <?php
7 
11 use Psr\Log\LoggerInterface;
14 
19 {
23  private $notifyDataChangedUrlPath = 'analytics/url/notify_data_changed';
24 
28  private $analyticsToken;
29 
33  private $httpClient;
34 
38  private $config;
39 
43  private $responseResolver;
44 
48  private $logger;
49 
58  public function __construct(
59  AnalyticsToken $analyticsToken,
60  Http\ClientInterface $httpClient,
61  ScopeConfigInterface $config,
62  ResponseResolver $responseResolver,
63  LoggerInterface $logger
64  ) {
65  $this->analyticsToken = $analyticsToken;
66  $this->httpClient = $httpClient;
67  $this->config = $config;
68  $this->responseResolver = $responseResolver;
69  $this->logger = $logger;
70  }
71 
77  public function execute()
78  {
79  $result = false;
80  if ($this->analyticsToken->isTokenExist()) {
81  $response = $this->httpClient->request(
82  ZendClient::POST,
83  $this->config->getValue($this->notifyDataChangedUrlPath),
84  [
85  "access-token" => $this->analyticsToken->getToken(),
86  "url" => $this->config->getValue(Store::XML_PATH_SECURE_BASE_URL),
87  ]
88  );
89  $result = $this->responseResolver->getResult($response);
90  }
91  return (bool)$result;
92  }
93 }
$response
Definition: 404.php:11
$config
Definition: fraud_order.php:17
$logger
__construct(AnalyticsToken $analyticsToken, Http\ClientInterface $httpClient, ScopeConfigInterface $config, ResponseResolver $responseResolver, LoggerInterface $logger)