Last active
August 29, 2015 14:02
-
-
Save MacDada/f60b59c12ee7bcc5c1b9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class BackupManager | |
{ | |
public function __construct($configOption1, $configOption2); | |
public function create(Entity $entity); | |
public function restore(Entity $entity); | |
public function remove(Entity $entity); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Command | |
{ | |
public function __construct(BackupManager $backupManager); | |
public function run(Entity $entity) | |
{ | |
$this->backupManager->create($entity); | |
try { | |
// work with $entity | |
} catch (Exception $e) { | |
$this->backupManager->restore($entity); | |
} | |
$this->backupManager->remove($entity); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment