@@ -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. |
@@ -129,9 +129,9 @@ |
||
| 129 | 129 | // Let's get the last modification date: |
| 130 | 130 | $tableDetail = $this->connection->getSchemaManager()->listTableDetails($tableName); |
| 131 | 131 | //We use createdTime instead of lastActivityTime when the field doesn't exist in order to follow changes. |
| 132 | - if($tableDetail->hasColumn('lastActivityTime')){ |
|
| 132 | + if ($tableDetail->hasColumn('lastActivityTime')) { |
|
| 133 | 133 | $lastActivityTime = $this->connection->fetchColumn('SELECT MAX(lastActivityTime) FROM '.$tableName); |
| 134 | - } else{ |
|
| 134 | + } else { |
|
| 135 | 135 | $lastActivityTime = $this->connection->fetchColumn('SELECT MAX(createdTime) FROM '.$tableName); |
| 136 | 136 | } |
| 137 | 137 | if ($lastActivityTime !== null) { |
@@ -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; |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | */ |
| 190 | 190 | private function getListFieldName(AbstractZohoDao $zohoDao) |
| 191 | 191 | { |
| 192 | - $fieldNames= array(); |
|
| 192 | + $fieldNames = array(); |
|
| 193 | 193 | foreach ($zohoDao->getFields() as $fieldsDescriptor) { |
| 194 | 194 | foreach (array_values($fieldsDescriptor) as $fieldDescriptor) { |
| 195 | 195 | $fieldNames[] = $fieldDescriptor['name']; |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | $zohoDao = new $daoFullClassName($this->zohoClient); |
| 214 | 214 | //To have more module which is use time of modification (createdTime or lastActivityTime). |
| 215 | 215 | //use an array of Excluded Dao by full namespace |
| 216 | - if (($this->excludedZohoDao && in_array(get_class($zohoDao),$this->excludedZohoDao)) || !in_array('createdTime', $this->getListFieldName($zohoDao))) { |
|
| 216 | + if (($this->excludedZohoDao && in_array(get_class($zohoDao), $this->excludedZohoDao)) || !in_array('createdTime', $this->getListFieldName($zohoDao))) { |
|
| 217 | 217 | continue; |
| 218 | 218 | } |
| 219 | 219 | $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 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | $statement->addSelect('l.field_name as updated_fieldname'); |
| 99 | 99 | } |
| 100 | 100 | $statement->from($localTable, 'l') |
| 101 | - ->join('l','('.$statementLimiter->getSQL().')','ll','ll.table_name = l.table_name and ll.uid = l.uid') |
|
| 101 | + ->join('l', '('.$statementLimiter->getSQL().')', 'll', 'll.table_name = l.table_name and ll.uid = l.uid') |
|
| 102 | 102 | ->join('l', $tableName, 'zcrm', 'zcrm.uid = l.uid') |
| 103 | 103 | ->where('l.table_name=:table_name') |
| 104 | 104 | ->setParameters([ |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | $rowsDeleted[] = $row['uid']; |
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | - $this->sendDataToZohoCleanLocal($zohoDao,$zohoBeans,$rowsDeleted,$update); |
|
| 133 | + $this->sendDataToZohoCleanLocal($zohoDao, $zohoBeans, $rowsDeleted, $update); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | * @param string[] $rowsDeleted |
| 140 | 140 | * @param bool $update |
| 141 | 141 | */ |
| 142 | - private function sendDataToZohoCleanLocal(AbstractZohoDao $zohoDao, array $zohoBeans,$rowsDeleted, $update = false) |
|
| 142 | + private function sendDataToZohoCleanLocal(AbstractZohoDao $zohoDao, array $zohoBeans, $rowsDeleted, $update = false) |
|
| 143 | 143 | { |
| 144 | 144 | $tableName = ZohoDatabaseHelper::getTableName($zohoDao, $this->prefix); |
| 145 | 145 | $zohoDao->save($zohoBeans); |
@@ -151,13 +151,13 @@ discard block |
||
| 151 | 151 | // ID not exist we can update the new row with the Zoho ID |
| 152 | 152 | $this->connection->beginTransaction(); |
| 153 | 153 | $this->connection->update($tableName, ['id' => $zohoBean->getZohoId()], ['uid' => $uid]); |
| 154 | - $this->connection->delete('local_insert', ['table_name'=>$tableName, 'uid' => $uid ]); |
|
| 154 | + $this->connection->delete('local_insert', ['table_name'=>$tableName, 'uid' => $uid]); |
|
| 155 | 155 | $this->connection->commit(); |
| 156 | 156 | } else { |
| 157 | 157 | //ID already exist we need to delete the duplicate row. |
| 158 | 158 | $this->connection->beginTransaction(); |
| 159 | - $this->connection->delete($tableName, ['uid' => $uid ]); |
|
| 160 | - $this->connection->delete('local_insert', ['table_name'=>$tableName, 'uid' => $uid ]); |
|
| 159 | + $this->connection->delete($tableName, ['uid' => $uid]); |
|
| 160 | + $this->connection->delete('local_insert', ['table_name'=>$tableName, 'uid' => $uid]); |
|
| 161 | 161 | $this->connection->commit(); |
| 162 | 162 | } |
| 163 | 163 | } |