1 | <?php |
||
22 | class Command |
||
23 | { |
||
24 | |||
25 | /** |
||
26 | * Process factory. |
||
27 | * |
||
28 | * @var IProcessFactory |
||
29 | */ |
||
30 | private $_processFactory; |
||
31 | |||
32 | /** |
||
33 | * Command line. |
||
34 | * |
||
35 | * @var string |
||
36 | */ |
||
37 | private $_commandLine; |
||
38 | |||
39 | /** |
||
40 | * Console IO. |
||
41 | * |
||
42 | * @var ConsoleIO |
||
43 | */ |
||
44 | private $_io; |
||
45 | |||
46 | /** |
||
47 | * Cache manager. |
||
48 | * |
||
49 | * @var CacheManager |
||
50 | */ |
||
51 | private $_cacheManager; |
||
52 | |||
53 | /** |
||
54 | * Cache duration. |
||
55 | * |
||
56 | * @var mixed |
||
57 | */ |
||
58 | private $_cacheDuration; |
||
59 | |||
60 | /** |
||
61 | * Text that when different from cached will invalidate the cache. |
||
62 | * |
||
63 | * @var string |
||
64 | */ |
||
65 | private $_cacheInvalidator; |
||
66 | |||
67 | /** |
||
68 | * Overwrites cached value regardless of it's expiration/invalidation settings. |
||
69 | * |
||
70 | * @var boolean |
||
71 | */ |
||
72 | private $_cacheOverwrite = false; |
||
73 | |||
74 | /** |
||
75 | * Creates a command instance. |
||
76 | * |
||
77 | * @param string $command_line Command line. |
||
78 | * @param ConsoleIO $io Console IO. |
||
79 | * @param CacheManager $cache_manager Cache manager. |
||
80 | * @param IProcessFactory $process_factory Process factory. |
||
81 | */ |
||
82 | 65 | public function __construct( |
|
93 | |||
94 | /** |
||
95 | * Set cache invalidator. |
||
96 | * |
||
97 | * @param string $invalidator Invalidator. |
||
98 | * |
||
99 | * @return self |
||
100 | */ |
||
101 | 16 | public function setCacheInvalidator($invalidator) |
|
107 | |||
108 | /** |
||
109 | * Set cache duration. |
||
110 | * |
||
111 | * @param mixed $duration Duration (seconds if numeric OR whatever "strtotime" accepts). |
||
112 | * |
||
113 | * @return self |
||
114 | */ |
||
115 | 39 | public function setCacheDuration($duration) |
|
121 | |||
122 | /** |
||
123 | * Set cache overwrite. |
||
124 | * |
||
125 | * @param boolean $cache_overwrite Cache replace. |
||
126 | * |
||
127 | * @return self |
||
128 | */ |
||
129 | 4 | public function setCacheOverwrite($cache_overwrite) |
|
135 | |||
136 | /** |
||
137 | * Runs the command. |
||
138 | * |
||
139 | * @param callable|null $callback Callback. |
||
140 | * |
||
141 | * @return string|\SimpleXMLElement |
||
142 | */ |
||
143 | 65 | public function run($callback = null) |
|
175 | |||
176 | /** |
||
177 | * Returns cache key for a command. |
||
178 | * |
||
179 | * @return string |
||
180 | */ |
||
181 | 65 | private function _getCacheKey() |
|
193 | |||
194 | /** |
||
195 | * Runs the command. |
||
196 | * |
||
197 | * @param callable|null $callback Callback. |
||
198 | * |
||
199 | * @return string |
||
200 | * @throws RepositoryCommandException When command execution failed. |
||
201 | */ |
||
202 | 34 | private function _doRun($callback = null) |
|
232 | |||
233 | /** |
||
234 | * Runs an svn command and displays output in real time. |
||
235 | * |
||
236 | * @param array $replacements Replacements for the output. |
||
237 | * |
||
238 | * @return string |
||
239 | */ |
||
240 | 2 | public function runLive(array $replacements = array()) |
|
244 | |||
245 | /** |
||
246 | * Creates "live output" callback. |
||
247 | * |
||
248 | * @param array $replacements Replacements for the output. |
||
249 | * |
||
250 | * @return callable |
||
251 | */ |
||
252 | 2 | private function _createLiveOutputCallback(array $replacements = array()) |
|
278 | |||
279 | } |
||
280 |