@@ -16,6 +16,7 @@ |
||
16 | 16 | * Computes the name of the table based on the DAO plural module name. |
17 | 17 | * |
18 | 18 | * @param AbstractZohoDao $dao |
19 | + * @param string $prefix |
|
19 | 20 | * |
20 | 21 | * @return string |
21 | 22 | */ |
@@ -6,7 +6,6 @@ |
||
6 | 6 | use Psr\Log\LoggerInterface; |
7 | 7 | use Psr\Log\NullLogger; |
8 | 8 | use Wabel\Zoho\CRM\AbstractZohoDao; |
9 | -use Wabel\Zoho\CRM\Request\Response; |
|
10 | 9 | |
11 | 10 | /** |
12 | 11 | * This class is in charge of synchronizing one table of your database with Zoho records. |
@@ -128,10 +128,10 @@ |
||
128 | 128 | // Let's get the last modification date: |
129 | 129 | $tableDetail = $this->connection->getSchemaManager()->listTableDetails($tableName); |
130 | 130 | $lastActivityTime = null; |
131 | - if($tableDetail->hasColumn('modifiedTime')){ |
|
131 | + if ($tableDetail->hasColumn('modifiedTime')) { |
|
132 | 132 | $lastActivityTime = $this->connection->fetchColumn('SELECT MAX(modifiedTime) FROM '.$tableName); |
133 | 133 | } |
134 | - if(!$lastActivityTime && $tableDetail->hasColumn('createdTime')) |
|
134 | + if (!$lastActivityTime && $tableDetail->hasColumn('createdTime')) |
|
135 | 135 | { |
136 | 136 | $lastActivityTime = $this->connection->fetchColumn('SELECT MAX(createdTime) FROM '.$tableName); |
137 | 137 | } |
@@ -7,7 +7,6 @@ |
||
7 | 7 | use Psr\Log\LoggerInterface; |
8 | 8 | use Psr\Log\NullLogger; |
9 | 9 | use Wabel\Zoho\CRM\AbstractZohoDao; |
10 | -use Wabel\Zoho\CRM\Request\Response; |
|
11 | 10 | |
12 | 11 | /** |
13 | 12 | * This class is in charge of synchronizing one table MODEL with Zoho. |
@@ -86,15 +86,15 @@ discard block |
||
86 | 86 | |
87 | 87 | $flatFields = ZohoDatabaseHelper::getFlatFields($dao->getFields()); |
88 | 88 | //@Temporary fix to use Mysql5.7 not strict |
89 | - $table->addColumn('uid', 'string', ['length' => 36,'notnull'=>false]); |
|
90 | - $table->addColumn('id', 'string', ['length' => 100,'notnull'=>false]); |
|
89 | + $table->addColumn('uid', 'string', ['length' => 36, 'notnull'=>false]); |
|
90 | + $table->addColumn('id', 'string', ['length' => 100, 'notnull'=>false]); |
|
91 | 91 | $table->addUniqueIndex(['id']); |
92 | 92 | $table->setPrimaryKey(['uid']); |
93 | 93 | |
94 | 94 | foreach ($flatFields as $field) { |
95 | 95 | $columnName = $field['name']; |
96 | 96 | //It seems sometime we can have the same field twice in the list of fields from the API. |
97 | - if($table->hasColumn($columnName)){ |
|
97 | + if ($table->hasColumn($columnName)) { |
|
98 | 98 | continue; |
99 | 99 | } |
100 | 100 | |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | $table = $schema->createTable($tableName); |
203 | 203 | |
204 | 204 | $flatFields = $users->getUserFields(); |
205 | - $table->addColumn('id', 'string', ['length' => 100,'notnull'=>false]); |
|
205 | + $table->addColumn('id', 'string', ['length' => 100, 'notnull'=>false]); |
|
206 | 206 | $table->setPrimaryKey(['id']); |
207 | 207 | foreach ($flatFields as $field) { |
208 | 208 | if (in_array($field, ['id'])) { |
@@ -49,7 +49,7 @@ |
||
49 | 49 | $localDelete = $schema->createTable('local_delete'); |
50 | 50 | $localDelete->addColumn('table_name', 'string', ['length' => 100]); |
51 | 51 | $localDelete->addColumn('uid', 'string', ['length' => 36]); |
52 | - $localDelete->addColumn('id', 'string', ['length' => 100,'notnull'=>false]); |
|
52 | + $localDelete->addColumn('id', 'string', ['length' => 100, 'notnull'=>false]); |
|
53 | 53 | $localDelete->setPrimaryKey(array('table_name', 'uid')); |
54 | 54 | $localDelete->addUniqueIndex(['id', 'table_name']); |
55 | 55 |
@@ -194,7 +194,6 @@ |
||
194 | 194 | |
195 | 195 | /** |
196 | 196 | * Regerate Zoho Daos |
197 | - * @param InputInterface $input |
|
198 | 197 | * @param OutputInterface $output |
199 | 198 | */ |
200 | 199 | private function regenerateZohoDao(OutputInterface $output) |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | $this->zohoDatabaseModelSync = $zohoDatabaseModelSync; |
100 | 100 | $this->zohoDatabaseCopier = $zohoDatabaseCopier; |
101 | 101 | $this->zohoDatabaseSync = $zohoDatabaseSync; |
102 | - $this->zohoEntitiesGenerator = $zohoEntitiesGenerator; |
|
102 | + $this->zohoEntitiesGenerator = $zohoEntitiesGenerator; |
|
103 | 103 | $this->zohoClient = $zohoClient; |
104 | 104 | $this->pathZohoDaos = $pathZohoDaos; |
105 | 105 | $this->namespaceZohoDaos = $namespaceZohoDaos; |
@@ -127,8 +127,8 @@ discard block |
||
127 | 127 | $this->lock->acquireLock(); |
128 | 128 | } |
129 | 129 | |
130 | - if(!$input->getOption('limit')){ |
|
131 | - ini_set('memory_limit','-1'); |
|
130 | + if (!$input->getOption('limit')) { |
|
131 | + ini_set('memory_limit', '-1'); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | $this->logger->addLogger(new DateTimeFormatter(new ConsoleLogger($output))); |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | */ |
195 | 195 | private function getListFieldName(AbstractZohoDao $zohoDao) |
196 | 196 | { |
197 | - $fieldNames= array(); |
|
197 | + $fieldNames = array(); |
|
198 | 198 | foreach ($zohoDao->getFields() as $fieldsDescriptor) { |
199 | 199 | foreach (array_values($fieldsDescriptor) as $fieldDescriptor) { |
200 | 200 | $fieldNames[] = $fieldDescriptor['name']; |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | $zohoDao = new $daoFullClassName($this->zohoClient); |
219 | 219 | //To have more module which is use time of modification (createdTime or lastActivityTime). |
220 | 220 | //use an array of Excluded Dao by full namespace |
221 | - if (($this->excludedZohoDao && in_array(get_class($zohoDao),$this->excludedZohoDao)) || !in_array('createdTime', $this->getListFieldName($zohoDao))) { |
|
221 | + if (($this->excludedZohoDao && in_array(get_class($zohoDao), $this->excludedZohoDao)) || !in_array('createdTime', $this->getListFieldName($zohoDao))) { |
|
222 | 222 | continue; |
223 | 223 | } |
224 | 224 | $this->zohoDaos [] = $zohoDao; |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | $this->logger = $logger; |
47 | 47 | } |
48 | 48 | $this->apiLimitInsertUpdateDelete = $apiLimitInsertUpdateDelete; |
49 | - if($apiLimitInsertUpdateDelete === null){ |
|
49 | + if ($apiLimitInsertUpdateDelete === null) { |
|
50 | 50 | $this->apiLimitInsertUpdateDelete = 100; |
51 | 51 | } |
52 | 52 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | $localTable = $update ? 'local_update' : 'local_insert'; |
100 | 100 | $fieldsMatching = $this->findMethodValues($zohoDao); |
101 | 101 | $tableName = ZohoDatabaseHelper::getTableName($zohoDao, $this->prefix); |
102 | - do{ |
|
102 | + do { |
|
103 | 103 | $rowsDeleted = []; |
104 | 104 | //@see https://www.zoho.com/crm/help/api/api-limits.html |
105 | 105 | //To optimize your API usage, get maximum 200 records with each request and insert, update or delete maximum 100 records with each request. |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $statement->addSelect('l.field_name as updated_fieldname'); |
113 | 113 | } |
114 | 114 | $statement->from($localTable, 'l') |
115 | - ->join('l','('.$statementLimiter->getSQL().')','ll','ll.table_name = l.table_name and ll.uid = l.uid') |
|
115 | + ->join('l', '('.$statementLimiter->getSQL().')', 'll', 'll.table_name = l.table_name and ll.uid = l.uid') |
|
116 | 116 | ->join('l', $tableName, 'zcrm', 'zcrm.uid = l.uid') |
117 | 117 | ->where('l.table_name=:table_name') |
118 | 118 | ->setParameters([ |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | $rowsDeleted[] = $row['uid']; |
145 | 145 | } |
146 | 146 | } |
147 | - $this->sendDataToZohoCleanLocal($zohoDao,$zohoBeans,$rowsDeleted,$update); |
|
148 | - $countToPush = $this->countElementInTable($zohoDao,$update); |
|
149 | - } while($countToPush > 0); |
|
147 | + $this->sendDataToZohoCleanLocal($zohoDao, $zohoBeans, $rowsDeleted, $update); |
|
148 | + $countToPush = $this->countElementInTable($zohoDao, $update); |
|
149 | + } while ($countToPush > 0); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * @param string[] $rowsDeleted |
156 | 156 | * @param bool $update |
157 | 157 | */ |
158 | - private function sendDataToZohoCleanLocal(AbstractZohoDao $zohoDao, array $zohoBeans,$rowsDeleted, $update = false) |
|
158 | + private function sendDataToZohoCleanLocal(AbstractZohoDao $zohoDao, array $zohoBeans, $rowsDeleted, $update = false) |
|
159 | 159 | { |
160 | 160 | $tableName = ZohoDatabaseHelper::getTableName($zohoDao, $this->prefix); |
161 | 161 | $zohoDao->save($zohoBeans); |
@@ -167,13 +167,13 @@ discard block |
||
167 | 167 | // ID not exist we can update the new row with the Zoho ID |
168 | 168 | $this->connection->beginTransaction(); |
169 | 169 | $this->connection->update($tableName, ['id' => $zohoBean->getZohoId()], ['uid' => $uid]); |
170 | - $this->connection->delete('local_insert', ['table_name'=>$tableName, 'uid' => $uid ]); |
|
170 | + $this->connection->delete('local_insert', ['table_name'=>$tableName, 'uid' => $uid]); |
|
171 | 171 | $this->connection->commit(); |
172 | 172 | } else { |
173 | 173 | //ID already exist we need to delete the duplicate row. |
174 | 174 | $this->connection->beginTransaction(); |
175 | - $this->connection->delete($tableName, ['uid' => $uid ]); |
|
176 | - $this->connection->delete('local_insert', ['table_name'=>$tableName, 'uid' => $uid ]); |
|
175 | + $this->connection->delete($tableName, ['uid' => $uid]); |
|
176 | + $this->connection->delete('local_insert', ['table_name'=>$tableName, 'uid' => $uid]); |
|
177 | 177 | $this->connection->commit(); |
178 | 178 | } |
179 | 179 | } |