1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @file |
5
|
|
|
* Magento API Client (SOAP v1). |
6
|
|
|
* Allows wrappers for each call, dependencies injections |
7
|
|
|
* and code completion. |
8
|
|
|
* |
9
|
|
|
* @author Sébastien MALOT <[email protected]> |
10
|
|
|
* @license MIT |
11
|
|
|
* @url <https://github.com/smalot/magento-client> |
12
|
|
|
* |
13
|
|
|
* For the full copyright and license information, please view the LICENSE |
14
|
|
|
* file that was distributed with this source code. |
15
|
|
|
*/ |
16
|
|
|
|
17
|
|
|
namespace Smalot\Magento; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Class Action |
21
|
|
|
* |
22
|
|
|
* @package Smalot\Magento |
23
|
|
|
*/ |
24
|
|
|
class Action implements ActionInterface |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* @var string |
28
|
|
|
*/ |
29
|
|
|
protected $method = null; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var array |
33
|
|
|
*/ |
34
|
|
|
protected $arguments = null; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var RemoteAdapterInterface |
38
|
|
|
*/ |
39
|
|
|
protected $remoteAdapter = null; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @param string $method |
43
|
|
|
* @param array $arguments |
44
|
|
|
* @param RemoteAdapterInterface $remoteAdapter |
45
|
|
|
*/ |
46
|
|
|
public function __construct($method, array $arguments = array(), RemoteAdapterInterface $remoteAdapter = null) |
47
|
|
|
{ |
48
|
|
|
$this->method = $method; |
49
|
|
|
$this->arguments = $arguments; |
50
|
|
|
$this->remoteAdapter = $remoteAdapter; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @return string |
55
|
|
|
*/ |
56
|
|
|
public function getMethod() |
57
|
|
|
{ |
58
|
|
|
return $this->method; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @return array |
63
|
|
|
*/ |
64
|
|
|
public function getArguments() |
65
|
|
|
{ |
66
|
|
|
return $this->arguments; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @return array |
71
|
|
|
*/ |
72
|
|
|
public function execute() |
73
|
|
|
{ |
74
|
|
|
return $this->remoteAdapter->call($this); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @param MultiCallQueueInterface $queue |
79
|
|
|
* @param callable $callback |
80
|
|
|
* |
81
|
|
|
* @return mixed|void |
82
|
|
|
*/ |
83
|
|
|
public function addToQueue(MultiCallQueueInterface $queue, $callback = null) |
84
|
|
|
{ |
85
|
|
|
$queue->addAction($this, $callback); |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|