1 | <?php |
||
22 | class PackageUpdateCommand extends AbstractPackageCommand |
||
23 | { |
||
24 | public function execute($queue) |
||
25 | { |
||
26 | $this->beforeRun(); |
||
27 | |||
28 | if (!$this->package->canBeUpdated()) { |
||
29 | if (!$this->packageRepository->exists($this->package)) { |
||
30 | $this->packageRepository->insert($this->package); |
||
31 | } |
||
32 | } else { |
||
33 | try { |
||
34 | $this->package->update(); |
||
35 | $this->packageRepository->save($this->package); |
||
36 | } catch (\Exception $e) { |
||
37 | Yii::error('Failed to update package "' . $this->package->getFullName() . '": ' . $e->getMessage(), __CLASS__); |
||
38 | $this->transformException($e); |
||
39 | |||
40 | throw $e; |
||
41 | } |
||
42 | |||
43 | $queue->push(Yii::createObject(CollectDependenciesCommand::class, [$this->package])); |
||
44 | } |
||
45 | |||
46 | $this->afterRun(); |
||
47 | } |
||
48 | |||
49 | private function transformException(\Exception $e) |
||
77 | } |
||
78 |