@@ -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 | */ |
@@ -202,7 +202,6 @@ |
||
202 | 202 | * Insert data to bean in order to update zoho records. |
203 | 203 | * |
204 | 204 | * @param ZohoBeanInterface $zohoBean |
205 | - * @param array $fieldsMatching |
|
206 | 205 | * @param type $columnName |
207 | 206 | * @param type $valueDb |
208 | 207 | */ |
@@ -230,26 +230,26 @@ |
||
230 | 230 | private function formatValueToBeans($type, $value) |
231 | 231 | { |
232 | 232 | switch ($type) { |
233 | - case 'date': |
|
234 | - $value = \DateTime::createFromFormat('Y-m-d', $value)?:null; |
|
235 | - break; |
|
236 | - case 'datetime': |
|
237 | - $value = \DateTime::createFromFormat('Y-m-d H:i:s', $value)?:null; |
|
238 | - break; |
|
239 | - case 'boolean' : |
|
240 | - $value = (bool) $value; |
|
241 | - break; |
|
242 | - case 'percent' : |
|
243 | - $value = (int) $value; |
|
244 | - break; |
|
245 | - case 'double' : |
|
246 | - $value = number_format($value, 2); |
|
247 | - break; |
|
248 | - case 'multiselectlookup': |
|
249 | - case 'multiuserlookup': |
|
250 | - case 'multiselectpicklist': |
|
251 | - $value = explode(';', $value); |
|
252 | - break; |
|
233 | + case 'date': |
|
234 | + $value = \DateTime::createFromFormat('Y-m-d', $value)?:null; |
|
235 | + break; |
|
236 | + case 'datetime': |
|
237 | + $value = \DateTime::createFromFormat('Y-m-d H:i:s', $value)?:null; |
|
238 | + break; |
|
239 | + case 'boolean' : |
|
240 | + $value = (bool) $value; |
|
241 | + break; |
|
242 | + case 'percent' : |
|
243 | + $value = (int) $value; |
|
244 | + break; |
|
245 | + case 'double' : |
|
246 | + $value = number_format($value, 2); |
|
247 | + break; |
|
248 | + case 'multiselectlookup': |
|
249 | + case 'multiuserlookup': |
|
250 | + case 'multiselectpicklist': |
|
251 | + $value = explode(';', $value); |
|
252 | + break; |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | return $value; |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $this->logger = $logger; |
48 | 48 | } |
49 | 49 | $this->apiLimitInsertUpdateDelete = $apiLimitInsertUpdateDelete; |
50 | - if($apiLimitInsertUpdateDelete === null) { |
|
50 | + if ($apiLimitInsertUpdateDelete === null) { |
|
51 | 51 | $this->apiLimitInsertUpdateDelete = 100; |
52 | 52 | } |
53 | 53 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | { |
82 | 82 | $localTable = $update ? 'local_update' : 'local_insert'; |
83 | 83 | $tableName = ZohoDatabaseHelper::getTableName($zohoDao, $this->prefix); |
84 | - do{ |
|
84 | + do { |
|
85 | 85 | $rowsDeleted = []; |
86 | 86 | //@see https://www.zoho.com/crm/help/api/v2/#ra-update-records |
87 | 87 | //To optimize your API usage, get maximum 200 records with each request and insert, update or delete maximum 100 records with each request. |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | $rowsDeleted[] = $row['uid']; |
129 | 129 | } |
130 | 130 | } |
131 | - if($zohoBeans) { |
|
131 | + if ($zohoBeans) { |
|
132 | 132 | $this->sendDataToZohoCleanLocal($zohoDao, $zohoBeans, $rowsDeleted, $update); |
133 | 133 | } |
134 | 134 | $countToPush = $this->countElementInTable($zohoDao, $update); |
135 | - } while($countToPush > 0); |
|
135 | + } while ($countToPush > 0); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @param string[] $rowsDeleted |
142 | 142 | * @param bool $update |
143 | 143 | */ |
144 | - private function sendDataToZohoCleanLocal(AbstractZohoDao $zohoDao, array $zohoBeans,$rowsDeleted, $update = false) |
|
144 | + private function sendDataToZohoCleanLocal(AbstractZohoDao $zohoDao, array $zohoBeans, $rowsDeleted, $update = false) |
|
145 | 145 | { |
146 | 146 | $tableName = ZohoDatabaseHelper::getTableName($zohoDao, $this->prefix); |
147 | 147 | $zohoDao->save($zohoBeans); |
@@ -153,13 +153,13 @@ discard block |
||
153 | 153 | // ID not exist we can update the new row with the Zoho ID |
154 | 154 | $this->connection->beginTransaction(); |
155 | 155 | $this->connection->update($tableName, ['id' => $zohoBean->getZohoId()], ['uid' => $uid]); |
156 | - $this->connection->delete('local_insert', ['table_name'=>$tableName, 'uid' => $uid ]); |
|
156 | + $this->connection->delete('local_insert', ['table_name'=>$tableName, 'uid' => $uid]); |
|
157 | 157 | $this->connection->commit(); |
158 | 158 | } else { |
159 | 159 | //ID already exist we need to delete the duplicate row. |
160 | 160 | $this->connection->beginTransaction(); |
161 | - $this->connection->delete($tableName, ['uid' => $uid ]); |
|
162 | - $this->connection->delete('local_insert', ['table_name'=>$tableName, 'uid' => $uid ]); |
|
161 | + $this->connection->delete($tableName, ['uid' => $uid]); |
|
162 | + $this->connection->delete('local_insert', ['table_name'=>$tableName, 'uid' => $uid]); |
|
163 | 163 | $this->connection->commit(); |
164 | 164 | } |
165 | 165 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | { |
188 | 188 | foreach ($row as $columnName => $columnValue) { |
189 | 189 | $fieldMethod = $dao->getFieldFromFieldName($columnName); |
190 | - if(!in_array($columnName, EntitiesGeneratorService::$defaultDateFields) && $fieldMethod |
|
190 | + if (!in_array($columnName, EntitiesGeneratorService::$defaultDateFields) && $fieldMethod |
|
191 | 191 | && (!in_array($columnName, ['id', 'uid'])) && !is_null($columnValue) |
192 | 192 | ) { |
193 | 193 | $type = $fieldMethod->getType(); |
@@ -231,10 +231,10 @@ discard block |
||
231 | 231 | { |
232 | 232 | switch ($type) { |
233 | 233 | case 'date': |
234 | - $value = \DateTime::createFromFormat('Y-m-d', $value)?:null; |
|
234 | + $value = \DateTime::createFromFormat('Y-m-d', $value) ?: null; |
|
235 | 235 | break; |
236 | 236 | case 'datetime': |
237 | - $value = \DateTime::createFromFormat('Y-m-d H:i:s', $value)?:null; |
|
237 | + $value = \DateTime::createFromFormat('Y-m-d H:i:s', $value) ?: null; |
|
238 | 238 | break; |
239 | 239 | case 'boolean' : |
240 | 240 | $value = (bool) $value; |
@@ -3,7 +3,6 @@ |
||
3 | 3 | |
4 | 4 | use Doctrine\DBAL\Connection; |
5 | 5 | use Doctrine\DBAL\Logging\SQLLogger; |
6 | -use Doctrine\DBAL\SQLParserUtils; |
|
7 | 6 | use function PHPSTORM_META\type; |
8 | 7 | use Psr\Log\LoggerInterface; |
9 | 8 |
@@ -57,7 +57,7 @@ |
||
57 | 57 | $query = null; |
58 | 58 | if ($params && $this->authorizedSQLWithParams) { |
59 | 59 | $this->logger->debug($sql.' -- Params : {params} - Types : {types}', ['params' => json_encode($params), 'types' => json_encode($types)]); |
60 | - } elseif($this->authorizedSQLWithoutParams) { |
|
60 | + } elseif ($this->authorizedSQLWithoutParams) { |
|
61 | 61 | $this->logger->debug($sql); |
62 | 62 | } |
63 | 63 | } |
@@ -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 | use zcrmsdk\crm\setup\users\ZCRMUser; |
12 | 11 | |
13 | 12 | /** |
@@ -110,75 +110,75 @@ discard block |
||
110 | 110 | $options = []; |
111 | 111 | // Note: full list of types available here: https://www.zoho.com/crm/help/customization/custom-fields.html |
112 | 112 | switch ($field->getType()) { |
113 | - case 'lookup': |
|
114 | - $type = 'string'; |
|
115 | - $length = $field->getMaxlength() && $field->getMaxlength() > 0?$field->getMaxlength() : 100; |
|
116 | - $index = true; |
|
117 | - break; |
|
118 | - case 'userlookup': |
|
119 | - case 'ownerlookup': |
|
120 | - $type = 'string'; |
|
121 | - $index = true; |
|
122 | - $length = $field->getMaxlength() && $field->getMaxlength() > 0?$field->getMaxlength() : 25; |
|
123 | - break; |
|
124 | - case 'formula': |
|
125 | - // Note: a Formula can return any type, but we have no way to know which type it returns... |
|
126 | - $type = 'string'; |
|
127 | - $length = $field->getMaxlength() && $field->getMaxlength() > 0?$field->getMaxlength() : 100; |
|
128 | - break; |
|
129 | - case 'datetime': |
|
130 | - $type = 'datetime'; |
|
131 | - break; |
|
132 | - case 'date': |
|
133 | - $type = 'date'; |
|
134 | - break; |
|
135 | - case 'boolean': |
|
136 | - $type = 'boolean'; |
|
137 | - break; |
|
138 | - case 'bigint': |
|
139 | - $type = 'bigint'; |
|
140 | - break; |
|
141 | - case 'fileupload': |
|
142 | - case 'phone': |
|
143 | - case 'text': |
|
144 | - case 'url': |
|
145 | - case 'email': |
|
146 | - case 'picklist': |
|
147 | - case 'website': |
|
148 | - $type = 'string'; |
|
149 | - $length = $field->getMaxlength() && $field->getMaxlength() > 0?$field->getMaxlength() : 255; |
|
150 | - break; |
|
151 | - case 'textarea': |
|
152 | - case 'multiselectlookup': |
|
153 | - case 'multiuserlookup': |
|
154 | - case 'multiselectpicklist': |
|
155 | - $type = 'text'; |
|
156 | - break; |
|
157 | - case 'percent': |
|
158 | - $type = 'integer'; |
|
159 | - break; |
|
160 | - case 'double': |
|
161 | - $type = 'float'; |
|
162 | - break; |
|
163 | - case 'autonumber': |
|
164 | - case 'integer': |
|
165 | - $type = 'integer'; |
|
166 | - $length = $field->getMaxlength() && $field->getMaxlength() > 0?$field->getMaxlength() : 255; |
|
167 | - break; |
|
168 | - case 'currency': |
|
169 | - case 'decimal': |
|
170 | - $type = 'decimal'; |
|
171 | - $options['scale'] = 2; |
|
172 | - break; |
|
173 | - case 'consent_lookup': |
|
174 | - case 'profileimage': |
|
175 | - case 'ALARM': |
|
176 | - case 'RRULE': |
|
177 | - case 'event_reminder': |
|
178 | - continue 2; |
|
113 | + case 'lookup': |
|
114 | + $type = 'string'; |
|
115 | + $length = $field->getMaxlength() && $field->getMaxlength() > 0?$field->getMaxlength() : 100; |
|
116 | + $index = true; |
|
117 | + break; |
|
118 | + case 'userlookup': |
|
119 | + case 'ownerlookup': |
|
120 | + $type = 'string'; |
|
121 | + $index = true; |
|
122 | + $length = $field->getMaxlength() && $field->getMaxlength() > 0?$field->getMaxlength() : 25; |
|
123 | + break; |
|
124 | + case 'formula': |
|
125 | + // Note: a Formula can return any type, but we have no way to know which type it returns... |
|
126 | + $type = 'string'; |
|
127 | + $length = $field->getMaxlength() && $field->getMaxlength() > 0?$field->getMaxlength() : 100; |
|
128 | + break; |
|
129 | + case 'datetime': |
|
130 | + $type = 'datetime'; |
|
131 | + break; |
|
132 | + case 'date': |
|
133 | + $type = 'date'; |
|
134 | + break; |
|
135 | + case 'boolean': |
|
136 | + $type = 'boolean'; |
|
137 | + break; |
|
138 | + case 'bigint': |
|
139 | + $type = 'bigint'; |
|
140 | + break; |
|
141 | + case 'fileupload': |
|
142 | + case 'phone': |
|
143 | + case 'text': |
|
144 | + case 'url': |
|
145 | + case 'email': |
|
146 | + case 'picklist': |
|
147 | + case 'website': |
|
148 | + $type = 'string'; |
|
149 | + $length = $field->getMaxlength() && $field->getMaxlength() > 0?$field->getMaxlength() : 255; |
|
150 | + break; |
|
151 | + case 'textarea': |
|
152 | + case 'multiselectlookup': |
|
153 | + case 'multiuserlookup': |
|
154 | + case 'multiselectpicklist': |
|
155 | + $type = 'text'; |
|
179 | 156 | break; |
180 | - default: |
|
181 | - throw new \RuntimeException('Unknown type "'.$field->getType().'"'); |
|
157 | + case 'percent': |
|
158 | + $type = 'integer'; |
|
159 | + break; |
|
160 | + case 'double': |
|
161 | + $type = 'float'; |
|
162 | + break; |
|
163 | + case 'autonumber': |
|
164 | + case 'integer': |
|
165 | + $type = 'integer'; |
|
166 | + $length = $field->getMaxlength() && $field->getMaxlength() > 0?$field->getMaxlength() : 255; |
|
167 | + break; |
|
168 | + case 'currency': |
|
169 | + case 'decimal': |
|
170 | + $type = 'decimal'; |
|
171 | + $options['scale'] = 2; |
|
172 | + break; |
|
173 | + case 'consent_lookup': |
|
174 | + case 'profileimage': |
|
175 | + case 'ALARM': |
|
176 | + case 'RRULE': |
|
177 | + case 'event_reminder': |
|
178 | + continue 2; |
|
179 | + break; |
|
180 | + default: |
|
181 | + throw new \RuntimeException('Unknown type "'.$field->getType().'"'); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | // For MySQL, the maximum row size is 65535 bytes. |
@@ -237,24 +237,24 @@ discard block |
||
237 | 237 | $length = null; |
238 | 238 | $index = false; |
239 | 239 | switch ($field) { |
240 | - case 'zuid': |
|
241 | - $type = 'string'; |
|
242 | - $length = 100; |
|
243 | - $index = true; |
|
244 | - break; |
|
245 | - case 'name': |
|
246 | - case 'email': |
|
247 | - $type = 'string'; |
|
248 | - $length = 255; |
|
249 | - $index = true; |
|
250 | - break; |
|
251 | - case 'phone': |
|
252 | - case 'website': |
|
253 | - $type = 'text'; |
|
254 | - break; |
|
255 | - default: |
|
256 | - $type = 'string'; |
|
257 | - $length = 100; |
|
240 | + case 'zuid': |
|
241 | + $type = 'string'; |
|
242 | + $length = 100; |
|
243 | + $index = true; |
|
244 | + break; |
|
245 | + case 'name': |
|
246 | + case 'email': |
|
247 | + $type = 'string'; |
|
248 | + $length = 255; |
|
249 | + $index = true; |
|
250 | + break; |
|
251 | + case 'phone': |
|
252 | + case 'website': |
|
253 | + $type = 'text'; |
|
254 | + break; |
|
255 | + default: |
|
256 | + $type = 'string'; |
|
257 | + $length = 100; |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | $options = []; |
@@ -93,15 +93,15 @@ discard block |
||
93 | 93 | $table = $schema->createTable($tableName); |
94 | 94 | |
95 | 95 | //@Temporary fix to use Mysql5.7 not strict |
96 | - $table->addColumn('uid', 'string', ['length' => 36,'notnull'=>false]); |
|
97 | - $table->addColumn('id', 'string', ['length' => 100,'notnull'=>false]); |
|
96 | + $table->addColumn('uid', 'string', ['length' => 36, 'notnull'=>false]); |
|
97 | + $table->addColumn('id', 'string', ['length' => 100, 'notnull'=>false]); |
|
98 | 98 | $table->addUniqueIndex(['id']); |
99 | 99 | $table->setPrimaryKey(['uid']); |
100 | 100 | |
101 | 101 | foreach ($dao->getFields() as $field) { |
102 | 102 | $columnName = $field->getName(); |
103 | 103 | //It seems sometime we can have the same field twice in the list of fields from the API. |
104 | - if($table->hasColumn($columnName)) { |
|
104 | + if ($table->hasColumn($columnName)) { |
|
105 | 105 | continue; |
106 | 106 | } |
107 | 107 | |
@@ -112,19 +112,19 @@ discard block |
||
112 | 112 | switch ($field->getType()) { |
113 | 113 | case 'lookup': |
114 | 114 | $type = 'string'; |
115 | - $length = $field->getMaxlength() && $field->getMaxlength() > 0?$field->getMaxlength() : 100; |
|
115 | + $length = $field->getMaxlength() && $field->getMaxlength() > 0 ? $field->getMaxlength() : 100; |
|
116 | 116 | $index = true; |
117 | 117 | break; |
118 | 118 | case 'userlookup': |
119 | 119 | case 'ownerlookup': |
120 | 120 | $type = 'string'; |
121 | 121 | $index = true; |
122 | - $length = $field->getMaxlength() && $field->getMaxlength() > 0?$field->getMaxlength() : 25; |
|
122 | + $length = $field->getMaxlength() && $field->getMaxlength() > 0 ? $field->getMaxlength() : 25; |
|
123 | 123 | break; |
124 | 124 | case 'formula': |
125 | 125 | // Note: a Formula can return any type, but we have no way to know which type it returns... |
126 | 126 | $type = 'string'; |
127 | - $length = $field->getMaxlength() && $field->getMaxlength() > 0?$field->getMaxlength() : 100; |
|
127 | + $length = $field->getMaxlength() && $field->getMaxlength() > 0 ? $field->getMaxlength() : 100; |
|
128 | 128 | break; |
129 | 129 | case 'datetime': |
130 | 130 | $type = 'datetime'; |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | case 'picklist': |
147 | 147 | case 'website': |
148 | 148 | $type = 'string'; |
149 | - $length = $field->getMaxlength() && $field->getMaxlength() > 0?$field->getMaxlength() : 255; |
|
149 | + $length = $field->getMaxlength() && $field->getMaxlength() > 0 ? $field->getMaxlength() : 255; |
|
150 | 150 | break; |
151 | 151 | case 'textarea': |
152 | 152 | case 'multiselectlookup': |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | case 'autonumber': |
164 | 164 | case 'integer': |
165 | 165 | $type = 'integer'; |
166 | - $length = $field->getMaxlength() && $field->getMaxlength() > 0?$field->getMaxlength() : 255; |
|
166 | + $length = $field->getMaxlength() && $field->getMaxlength() > 0 ? $field->getMaxlength() : 255; |
|
167 | 167 | break; |
168 | 168 | case 'currency': |
169 | 169 | case 'decimal': |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | $schema = new Schema(); |
228 | 228 | $table = $schema->createTable($tableName); |
229 | 229 | |
230 | - $table->addColumn('id', 'string', ['length' => 100,'notnull'=>false]); |
|
230 | + $table->addColumn('id', 'string', ['length' => 100, 'notnull'=>false]); |
|
231 | 231 | $table->setPrimaryKey(['id']); |
232 | 232 | foreach (ZCRMUser::$defaultKeys as $field) { |
233 | 233 | if ($field === 'id') { |
@@ -15,7 +15,6 @@ |
||
15 | 15 | use Logger\Formatters\DateTimeFormatter; |
16 | 16 | use Mouf\Utils\Log\Psr\MultiLogger; |
17 | 17 | use Wabel\Zoho\CRM\Request\Response; |
18 | -use zcrmsdk\crm\utility\ZCRMConfigUtil; |
|
19 | 18 | |
20 | 19 | class ZohoSyncDatabaseCommand extends Command |
21 | 20 | { |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | $this->zohoDatabaseModelSync = $zohoDatabaseModelSync; |
102 | 102 | $this->zohoDatabaseCopier = $zohoDatabaseCopier; |
103 | 103 | $this->zohoDatabaseSync = $zohoDatabaseSync; |
104 | - $this->zohoEntitiesGenerator = $zohoEntitiesGenerator; |
|
104 | + $this->zohoEntitiesGenerator = $zohoEntitiesGenerator; |
|
105 | 105 | $this->zohoClient = $zohoClient; |
106 | 106 | $this->pathZohoDaos = $pathZohoDaos; |
107 | 107 | $this->namespaceZohoDaos = $namespaceZohoDaos; |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | if ($input->getOption('log-path') && $input->getOption('clear-logs')) { |
139 | 139 | $this->logger->notice('Clearing logs...'); |
140 | 140 | $path = $input->getOption('log-path'); |
141 | - $logFile = $path . '/ZCRMClientLibrary.log'; |
|
141 | + $logFile = $path.'/ZCRMClientLibrary.log'; |
|
142 | 142 | if (file_exists($logFile)) { |
143 | 143 | if (is_writable($logFile)) { |
144 | 144 | if (file_put_contents($logFile, '') === false) { |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | } |
153 | 153 | } |
154 | 154 | |
155 | - if(!$input->getOption('limit')) { |
|
155 | + if (!$input->getOption('limit')) { |
|
156 | 156 | ini_set('memory_limit', '-1'); |
157 | 157 | } |
158 | 158 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | if ($input->getOption('log-path') && $input->getOption('dump-logs')) { |
178 | 178 | $this->logger->info('Dumping logs...'); |
179 | 179 | $path = $input->getOption('log-path'); |
180 | - $logFile = $path . '/ZCRMClientLibrary.log'; |
|
180 | + $logFile = $path.'/ZCRMClientLibrary.log'; |
|
181 | 181 | if (file_exists($logFile)) { |
182 | 182 | if (is_readable($logFile)) { |
183 | 183 | $this->logger->info(file_get_contents($logFile)); |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | { |
292 | 292 | $this->logger->notice('Starting to push data from local database into Zoho CRM...'); |
293 | 293 | foreach ($this->zohoDaos as $zohoDao) { |
294 | - if($zohoDao->getFieldFromFieldName('createdTime')) { |
|
294 | + if ($zohoDao->getFieldFromFieldName('createdTime')) { |
|
295 | 295 | $this->zohoDatabaseSync->pushToZoho($zohoDao); |
296 | 296 | } |
297 | 297 | } |
@@ -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 | use zcrmsdk\crm\crud\ZCRMRecord; |
11 | 10 | use zcrmsdk\crm\exception\ZCRMException; |
12 | 11 |
@@ -71,11 +71,11 @@ discard block |
||
71 | 71 | { |
72 | 72 | $users = $this->zohoUserService->getUsers(); |
73 | 73 | $tableName = 'users'; |
74 | - $this->logger->info('Fetched ' . count($users) . ' records'); |
|
74 | + $this->logger->info('Fetched '.count($users).' records'); |
|
75 | 75 | |
76 | 76 | $table = $this->connection->getSchemaManager()->createSchema()->getTable($tableName); |
77 | 77 | |
78 | - $select = $this->connection->prepare('SELECT * FROM ' . $tableName . ' WHERE id = :id'); |
|
78 | + $select = $this->connection->prepare('SELECT * FROM '.$tableName.' WHERE id = :id'); |
|
79 | 79 | |
80 | 80 | $this->connection->beginTransaction(); |
81 | 81 | foreach ($users as $user) { |
@@ -112,14 +112,14 @@ discard block |
||
112 | 112 | $select->execute(['id' => $user->getId()]); |
113 | 113 | $result = $select->fetch(\PDO::FETCH_ASSOC); |
114 | 114 | if ($result === false && $data) { |
115 | - $this->logger->debug("Inserting record with ID '" . $user->getId() . "'."); |
|
115 | + $this->logger->debug("Inserting record with ID '".$user->getId()."'."); |
|
116 | 116 | |
117 | 117 | $data['id'] = $user->getId(); |
118 | 118 | $types['id'] = 'string'; |
119 | 119 | |
120 | 120 | $this->connection->insert($tableName, $data, $types); |
121 | 121 | } elseif ($data) { |
122 | - $this->logger->debug("Updating record with ID '" . $user->getId() . "'."); |
|
122 | + $this->logger->debug("Updating record with ID '".$user->getId()."'."); |
|
123 | 123 | $identifier = ['id' => $user->getId()]; |
124 | 124 | $types['id'] = 'string'; |
125 | 125 | $this->connection->update($tableName, $data, $identifier, $types); |
@@ -150,15 +150,15 @@ discard block |
||
150 | 150 | $tableDetail = $this->connection->getSchemaManager()->listTableDetails($tableName); |
151 | 151 | $lastActivityTime = null; |
152 | 152 | if ($tableDetail->hasColumn('modifiedTime')) { |
153 | - $lastActivityTime = $this->connection->fetchColumn('SELECT MAX(modifiedTime) FROM ' . $tableName); |
|
153 | + $lastActivityTime = $this->connection->fetchColumn('SELECT MAX(modifiedTime) FROM '.$tableName); |
|
154 | 154 | } |
155 | 155 | if (!$lastActivityTime && $tableDetail->hasColumn('createdTime')) { |
156 | - $lastActivityTime = $this->connection->fetchColumn('SELECT MAX(createdTime) FROM ' . $tableName); |
|
156 | + $lastActivityTime = $this->connection->fetchColumn('SELECT MAX(createdTime) FROM '.$tableName); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | if ($lastActivityTime !== null) { |
160 | 160 | $lastActivityTime = new \DateTime($lastActivityTime, new \DateTimeZone($dao->getZohoClient()->getTimezone())); |
161 | - $this->logger->info('Last modified time: ' . $lastActivityTime->format(\DateTime::ATOM)); |
|
161 | + $this->logger->info('Last modified time: '.$lastActivityTime->format(\DateTime::ATOM)); |
|
162 | 162 | // Let's add one second to the last activity time (otherwise, we are fetching again the last record in DB). |
163 | 163 | $lastActivityTime->add(new \DateInterval('PT1S')); |
164 | 164 | } |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | $deletedRecords = []; |
172 | 172 | } |
173 | 173 | } catch (ZCRMException $exception) { |
174 | - $this->logger->error('Error when getting records for module ' . $tableName . ': ' . $exception->getMessage(), [ |
|
174 | + $this->logger->error('Error when getting records for module '.$tableName.': '.$exception->getMessage(), [ |
|
175 | 175 | 'exception' => $exception |
176 | 176 | ]); |
177 | 177 | if ($throwErrors) { |
@@ -179,11 +179,11 @@ discard block |
||
179 | 179 | } |
180 | 180 | return; |
181 | 181 | } |
182 | - $this->logger->info('Fetched ' . count($records) . ' records'); |
|
182 | + $this->logger->info('Fetched '.count($records).' records'); |
|
183 | 183 | |
184 | 184 | $table = $this->connection->getSchemaManager()->createSchema()->getTable($tableName); |
185 | 185 | |
186 | - $select = $this->connection->prepare('SELECT * FROM ' . $tableName . ' WHERE id = :id'); |
|
186 | + $select = $this->connection->prepare('SELECT * FROM '.$tableName.' WHERE id = :id'); |
|
187 | 187 | |
188 | 188 | $this->connection->beginTransaction(); |
189 | 189 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | $select->execute(['id' => $record->getZohoId()]); |
217 | 217 | $result = $select->fetch(\PDO::FETCH_ASSOC); |
218 | 218 | if ($result === false) { |
219 | - $this->logger->debug("Inserting record with ID '" . $record->getZohoId() . "'."); |
|
219 | + $this->logger->debug("Inserting record with ID '".$record->getZohoId()."'."); |
|
220 | 220 | |
221 | 221 | $data['id'] = $record->getZohoId(); |
222 | 222 | $types['id'] = 'string'; |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | $listener->onInsert($data, $dao); |
228 | 228 | } |
229 | 229 | } else { |
230 | - $this->logger->debug("Updating record with ID '" . $record->getZohoId() . "'."); |
|
230 | + $this->logger->debug("Updating record with ID '".$record->getZohoId()."'."); |
|
231 | 231 | $identifier = ['id' => $record->getZohoId()]; |
232 | 232 | $types['id'] = 'string'; |
233 | 233 | |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | } |
241 | 241 | } |
242 | 242 | } |
243 | - $sqlStatementUid = 'select uid from ' . $this->connection->quoteIdentifier($tableName) . ' where id = :id'; |
|
243 | + $sqlStatementUid = 'select uid from '.$this->connection->quoteIdentifier($tableName).' where id = :id'; |
|
244 | 244 | foreach ($deletedRecords as $deletedRecord) { |
245 | 245 | $uid = $this->connection->fetchColumn($sqlStatementUid, ['id' => $deletedRecord->getEntityId()]); |
246 | 246 | $this->connection->delete($tableName, ['id' => $deletedRecord->getEntityId()]); |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | $this->connection->delete('local_update', ['table_name' => $tableName, 'uid' => $uid]); |
252 | 252 | } |
253 | 253 | } |
254 | - $this->logger->info('Deleted ' . count($deletedRecords) . ' records'); |
|
254 | + $this->logger->info('Deleted '.count($deletedRecords).' records'); |
|
255 | 255 | |
256 | 256 | $this->connection->commit(); |
257 | 257 | } |
@@ -49,7 +49,7 @@ discard block |
||
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 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | public function createUuidInsertTrigger(Table $table) |
90 | 90 | { |
91 | 91 | $triggerName = sprintf('TRG_%s_SETUUIDBEFOREINSERT', $table->getName()); |
92 | - $this->logger->info('Creating ' . $triggerName . ' trigger for table ' . $table->getName() . '...'); |
|
92 | + $this->logger->info('Creating '.$triggerName.' trigger for table '.$table->getName().'...'); |
|
93 | 93 | |
94 | 94 | //Fix - temporary MySQL 5.7 strict mode |
95 | 95 | $sql = sprintf( |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | public function createInsertTrigger(Table $table) |
119 | 119 | { |
120 | 120 | $triggerName = sprintf('TRG_%s_ONINSERT', $table->getName()); |
121 | - $this->logger->info('Creating ' . $triggerName . ' trigger for table ' . $table->getName() . '...'); |
|
121 | + $this->logger->info('Creating '.$triggerName.' trigger for table '.$table->getName().'...'); |
|
122 | 122 | |
123 | 123 | $tableNameQuoted = $this->connection->quote($table->getName()); |
124 | 124 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | public function createDeleteTrigger(Table $table) |
146 | 146 | { |
147 | 147 | $triggerName = sprintf('TRG_%s_ONDELETE', $table->getName()); |
148 | - $this->logger->info('Creating ' . $triggerName . ' trigger for table ' . $table->getName() . '...'); |
|
148 | + $this->logger->info('Creating '.$triggerName.' trigger for table '.$table->getName().'...'); |
|
149 | 149 | |
150 | 150 | $tableNameQuoted = $this->connection->quote($table->getName()); |
151 | 151 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | public function createUpdateTrigger(Table $table) |
173 | 173 | { |
174 | 174 | $triggerName = sprintf('TRG_%s_ONUPDATE', $table->getName()); |
175 | - $this->logger->info('Creating ' . $triggerName . ' trigger for table ' . $table->getName() . '...'); |
|
175 | + $this->logger->info('Creating '.$triggerName.' trigger for table '.$table->getName().'...'); |
|
176 | 176 | |
177 | 177 | $innerCode = ''; |
178 | 178 |