Open Journal Systems  3.3.0
CommandTransferException.php
1 <?php
2 
4 
7 
12 {
13  protected $successfulCommands = array();
14  protected $failedCommands = array();
15 
24  {
25  $ce = new self($e->getMessage(), $e->getCode(), $e->getPrevious());
26  $ce->setSuccessfulRequests($e->getSuccessfulRequests());
27 
28  $alreadyAddedExceptions = array();
29  foreach ($e->getFailedRequests() as $request) {
30  if ($re = $e->getExceptionForFailedRequest($request)) {
31  $alreadyAddedExceptions[] = $re;
32  $ce->addFailedRequestWithException($request, $re);
33  } else {
34  $ce->addFailedRequest($request);
35  }
36  }
37 
38  // Add any exceptions that did not map to a request
39  if (count($alreadyAddedExceptions) < count($e)) {
40  foreach ($e as $ex) {
41  if (!in_array($ex, $alreadyAddedExceptions)) {
42  $ce->add($ex);
43  }
44  }
45  }
46 
47  return $ce;
48  }
49 
55  public function getAllCommands()
56  {
57  return array_merge($this->successfulCommands, $this->failedCommands);
58  }
59 
67  public function addSuccessfulCommand(CommandInterface $command)
68  {
69  $this->successfulCommands[] = $command;
70 
71  return $this;
72  }
73 
81  public function addFailedCommand(CommandInterface $command)
82  {
83  $this->failedCommands[] = $command;
84 
85  return $this;
86  }
87 
93  public function getSuccessfulCommands()
94  {
96  }
97 
103  public function getFailedCommands()
104  {
105  return $this->failedCommands;
106  }
107 
116  {
117  return $this->getExceptionForFailedRequest($command->getRequest());
118  }
119 }
Guzzle\Service\Exception\CommandTransferException\addSuccessfulCommand
addSuccessfulCommand(CommandInterface $command)
Definition: CommandTransferException.php:67
Guzzle\Http\Exception\MultiTransferException\getFailedRequests
getFailedRequests()
Definition: MultiTransferException.php:129
Guzzle\Service\Exception\CommandTransferException\getSuccessfulCommands
getSuccessfulCommands()
Definition: CommandTransferException.php:93
Guzzle\Http\Exception\MultiTransferException\getExceptionForFailedRequest
getExceptionForFailedRequest(RequestInterface $request)
Definition: MultiTransferException.php:79
Guzzle\Service\Exception\CommandTransferException\fromMultiTransferException
static fromMultiTransferException(MultiTransferException $e)
Definition: CommandTransferException.php:23
Guzzle\Service\Exception\CommandTransferException\getExceptionForFailedCommand
getExceptionForFailedCommand(CommandInterface $command)
Definition: CommandTransferException.php:115
Guzzle\Http\Exception\MultiTransferException
Definition: MultiTransferException.php:11
Guzzle\Service\Exception\CommandTransferException\addFailedCommand
addFailedCommand(CommandInterface $command)
Definition: CommandTransferException.php:81
Guzzle\Service\Command\CommandInterface
Definition: CommandInterface.php:17
Guzzle\Service\Exception
Definition: CommandException.php:3
Guzzle\Service\Exception\CommandTransferException\getAllCommands
getAllCommands()
Definition: CommandTransferException.php:55
Guzzle\Service\Exception\CommandTransferException\getFailedCommands
getFailedCommands()
Definition: CommandTransferException.php:103
Guzzle\Common\Exception\ExceptionCollection\count
count()
Definition: ExceptionCollection.php:69
Guzzle\Service\Exception\CommandTransferException\$failedCommands
$failedCommands
Definition: CommandTransferException.php:14
Guzzle\Service\Exception\CommandTransferException
Definition: CommandTransferException.php:11
Guzzle\Service\Command\CommandInterface\getRequest
getRequest()
Guzzle\Http\Exception\MultiTransferException\getSuccessfulRequests
getSuccessfulRequests()
Definition: MultiTransferException.php:119
Guzzle\Service\Exception\CommandTransferException\$successfulCommands
$successfulCommands
Definition: CommandTransferException.php:13