This repository has been archived by the owner on Mar 24, 2023. It is now read-only.
/
AbstractRequest.php
117 lines (100 loc) · 2.82 KB
/
AbstractRequest.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
/**
* AbstractRequest.php
*
* NOTICE OF LICENSE
*
* This source file is subject to the MIT License, which
* is bundled with this package in the file LICENSE.txt.
*
* It is also available on the Internet at the following URL:
* https://docs.auroraextensions.com/magento/extensions/2.x/magentocroncloudfunctions/LICENSE.txt
*
* @package AuroraExtensions_MagentoCronCloudFunctions
* @copyright Copyright (C) 2019 Aurora Extensions <support@auroraextensions.com>
* @license MIT License
*/
namespace AuroraExtensions\MagentoCronCloudFunctions\Model\Http;
use AuroraExtensions\MagentoCronCloudFunctions\Helper\Cron as CronHelper;
use AuroraExtensions\MagentoCronCloudFunctions\Helper\Dict;
use AuroraExtensions\MagentoCronCloudFunctions\Model\Cron\JobInterface;
use Magento\Framework\DataObject;
use Zend\Http\Request as HttpRequest;
abstract class AbstractRequest extends DataObject implements RequestInterface
{
/** @property CronHelper $cronHelper */
protected $cronHelper;
/** @property JobInterface $cronJob */
protected $cronJob;
/** @property HeadersInterface $headers */
protected $headers;
/** @property HttpRequest $request */
protected $request;
/** @property TransportInterface $transport */
protected $transport;
/**
* @param CronHelper $cronHelper
* @param JobInterface $cronJob
* @param HeadersInterface $httpHeaders
* @param RequestInterface $httpRequest
* @param TransportInterface $transport
*/
public function __construct(
CronHelper $cronHelper,
JobInterface $cronJob,
HeadersInterface $headers,
HttpRequest $request,
TransportInterface $transport,
array $data = []
) {
$this->cronHelper = $cronHelper;
$this->cronJob = $cronJob;
$this->headers = $headers;
$this->request = $request;
$this->transport = $transport;
parent::__construct($data);
}
/**
* Get Zend HTTP request object.
*
* @return HttpRequest
*/
public function getHttpRequest()
{
return $this->request;
}
/**
* Set HTTP headers for request.
*
* @param array $headers
* @return $this
*/
public function setHeaders(array $headers = [])
{
$this->headers->addHeaders($headers);
$this->request->setHeaders($this->headers);
return $this;
}
/**
* Set HTTP method for request.
*
* @param string $method
* @return $this
*/
public function setMethod($method)
{
$this->request->setMethod($method);
return $this;
}
/**
* Set HTTP endpoint URI.
*
* @param string $uri
* @return $this
*/
public function setUri($uri)
{
$this->request->setUri($uri);
return $this;
}
}