1: <?php
2:
3: namespace webfilesframework\core\datastore;
4:
5:
6:
7: 8: 9: 10: 11: 12:
13: class MDatastoreTransfer
14: {
15:
16: private $source;
17: private $target;
18:
19: function __construct(MAbstractDatastore $source, MAbstractDatastore $target)
20: {
21: if ($source == null) {
22: throw new MDatastoreException("source datastore cannot be null.");
23: }
24: if ($target == null) {
25: throw new MDatastoreException("target datastore cannot be null.");
26: }
27:
28: $this->source = $source;
29: $this->target = $target;
30: }
31:
32: function transfer()
33: {
34:
35: if ($this->target->isReadOnly()) {
36: throw new MDatastoreException("Cannot transfer data to a read-only datastore.");
37: }
38:
39: $webfiles = $this->source->getWebfilesAsStream();
40: $this->target->storeWebfilesFromStream($webfiles);
41: }
42: }