1: <?php
2: namespace Datadepo\Api;
3:
4: class DataDepoSync
5: {
6:
7:
8: protected $iniConfiguration;
9:
10:
11: protected $dataStore;
12:
13:
14:
15: private $dataStoreConnected = FALSE;
16:
17: 18: 19: 20:
21: public function __construct(DataStores\IDataStore $dataStore, IniConfiguration $iniConfiguration)
22: {
23: $this->dataStore = $dataStore;
24: $this->iniConfiguration = $iniConfiguration;
25: }
26:
27: 28: 29: 30:
31: public function data()
32: {
33: return $this->synchronize(new Synchronizers\DataSynchronizer($this->dataStore, $this->iniConfiguration));
34: }
35:
36: 37: 38: 39:
40: public function business()
41: {
42: return $this->synchronize(new Synchronizers\BusinessSynchronizer($this->dataStore, $this->iniConfiguration));
43: }
44:
45: 46: 47: 48:
49: public function suppliers()
50: {
51: return $this->synchronize(new Synchronizers\SuppliersSynchronizer($this->dataStore, $this->iniConfiguration));
52: }
53:
54: 55: 56: 57:
58: public function categories()
59: {
60: return $this->synchronize(new Synchronizers\CategorySynchronizer($this->dataStore, $this->iniConfiguration));
61: }
62:
63: 64: 65: 66:
67: protected function synchronize(Synchronizers\AbstractSynchronizer $synchronizer)
68: {
69: $this->connect();
70: return $synchronizer->sync();
71: }
72:
73:
74: 75:
76: protected function connect()
77: {
78: if (!$this->dataStoreConnected) {
79: $this->dataStore->setIniConfiguration($this->iniConfiguration);
80: $this->dataStore->connect();
81: }
82: }
83:
84:
85: }