@@ 30-71 (lines=42) @@ | ||
27 | * |
|
28 | * @package RunOpenCode\Backup\Workflow |
|
29 | */ |
|
30 | class PostRotate extends BaseActivity implements LoggerAwareInterface, EventDispatcherAwareInterface |
|
31 | { |
|
32 | use LoggerAwareTrait; |
|
33 | use EventDispatcherAwareTrait; |
|
34 | ||
35 | /** |
|
36 | * {@inheritdoc} |
|
37 | */ |
|
38 | public function execute() |
|
39 | { |
|
40 | try { |
|
41 | ||
42 | $nominations = $this->profile->getPostRotator()->nominate($this->profile->getDestination()->all()); |
|
43 | ||
44 | if ($count = count($nominations) > 0) { |
|
45 | ||
46 | /** |
|
47 | * @var BackupInterface $nomination |
|
48 | */ |
|
49 | foreach ($nominations as $nomination) { |
|
50 | ||
51 | $this->profile->getDestination()->delete($nomination->getName()); |
|
52 | } |
|
53 | } |
|
54 | ||
55 | $this->getLogger()->info(sprintf('Post-rotation successfully executed, %s backups rotated.', $count)); |
|
56 | $this->getEventDispatcher()->dispatch(BackupEvents::POST_ROTATE, new BackupEvent($this, $this->profile, $this->backup, $this)); |
|
57 | ||
58 | } catch (\Exception $e) { |
|
59 | ||
60 | $this->getLogger()->error(sprintf('Could not execute post-rotation for profile "%s".', $this->profile->getName()), array( |
|
61 | 'message' => $e->getMessage(), |
|
62 | 'code' => $e->getCode(), |
|
63 | 'file' => $e->getFile(), |
|
64 | 'line' => $e->getLine(), |
|
65 | 'trace' => $e->getTrace() |
|
66 | )); |
|
67 | ||
68 | throw $e; |
|
69 | } |
|
70 | } |
|
71 | } |
@@ 32-73 (lines=42) @@ | ||
29 | * |
|
30 | * @package RunOpenCode\Backup\Workflow |
|
31 | */ |
|
32 | class PreRotate extends BaseActivity implements LoggerAwareInterface, EventDispatcherAwareInterface |
|
33 | { |
|
34 | use LoggerAwareTrait; |
|
35 | use EventDispatcherAwareTrait; |
|
36 | ||
37 | /** |
|
38 | * {@inheritdoc} |
|
39 | */ |
|
40 | public function execute() |
|
41 | { |
|
42 | try { |
|
43 | ||
44 | $nominations = $this->profile->getPreRotator()->nominate($this->profile->getDestination()->all()); |
|
45 | ||
46 | if ($count = count($nominations) > 0) { |
|
47 | ||
48 | /** |
|
49 | * @var BackupInterface $nomination |
|
50 | */ |
|
51 | foreach ($nominations as $nomination) { |
|
52 | ||
53 | $this->profile->getDestination()->delete($nomination->getName()); |
|
54 | } |
|
55 | } |
|
56 | ||
57 | $this->getLogger()->info(sprintf('Pre-rotation successfully executed, %s backups rotated.', $count)); |
|
58 | $this->getEventDispatcher()->dispatch(BackupEvents::PRE_ROTATE, new BackupEvent($this, $this->profile, $this->backup, $this)); |
|
59 | ||
60 | } catch (\Exception $e) { |
|
61 | ||
62 | $this->getLogger()->error(sprintf('Could not execute pre-rotation for profile "%s".', $this->profile->getName()), array( |
|
63 | 'message' => $e->getMessage(), |
|
64 | 'code' => $e->getCode(), |
|
65 | 'file' => $e->getFile(), |
|
66 | 'line' => $e->getLine(), |
|
67 | 'trace' => $e->getTrace() |
|
68 | )); |
|
69 | ||
70 | throw $e; |
|
71 | } |
|
72 | } |
|
73 | } |