/** * Set the cleanup configuration. * * @param \phpbu\App\Configuration\Backup $backup * @param array $json * @throws \phpbu\App\Exception */ protected function setCleanup(Configuration\Backup $backup, array $json) { if (isset($json['cleanup'])) { if (!isset($json['cleanup']['type'])) { throw new Exception('invalid cleanup configuration: type missing'); } $type = $json['cleanup']['type']; $skip = Arr::getValue($json['cleanup'], 'skipOnFailure', true); $options = $this->getOptions($json['cleanup']); $backup->setCleanup(new Configuration\Backup\Cleanup($type, $skip, $options)); } }
/** * Set the cleanup configuration. * * @param \phpbu\App\Configuration\Backup $backup * @param \DOMElement $node * @throws \phpbu\App\Exception */ protected function setCleanup(Configuration\Backup $backup, DOMElement $node) { /** @var \DOMNodeList $cleanupNodes */ $cleanupNodes = $node->getElementsByTagName('cleanup'); if ($cleanupNodes->length > 0) { /** @var \DOMElement $cleanupNode */ $cleanupNode = $cleanupNodes->item(0); $type = $cleanupNode->getAttribute('type'); if (!$type) { throw new Exception('invalid cleanup configuration: attribute type missing'); } $skip = Str::toBoolean($cleanupNode->getAttribute('skipOnFailure'), true); $options = $this->getOptions($cleanupNode); $backup->setCleanup(new Configuration\Backup\Cleanup($type, $skip, $options)); } }