29 Loader::includeModule(
'dav');
30 DavConnectionTable::update($connection->getId(), $fields);
58 if (!Loader::includeModule(
'dav'))
63 $connection = DavConnectionTable::query()
85 return (
new Sync\Builders\BuilderConnectionFromDM($objectEO))->build();
93 return 'Dav connection';
106 Loader::includeModule(
'dav');
107 $data = $this->convertToArray($entity);
109 $result = DavConnectionTable::add($data);
110 if ($result->isSuccess())
112 return $entity->setId($result->getId());
128 Loader::includeModule(
'dav');
129 $data = $this->convertToArray($entity);
130 unset($data[
'CREATED']);
132 $result = DavConnectionTable::update($entity->getId(), $data);
133 if ($result->isSuccess())
141 private function convertToArray($connection): array
144 'SYNC_TOKEN' => $connection->getToken(),
145 'NAME' => $connection->getName(),
146 'ENTITY_TYPE' => $connection->getOwner()->getType(),
147 'ENTITY_ID' => $connection->getOwner()->getId(),
148 'SERVER_SCHEME' => $connection->getServer()->getScheme(),
149 'SERVER_HOST' => $connection->getServer()->getHost(),
150 'SERVER_PORT' => $connection->getServer()->getPort(),
151 'SERVER_USERNAME' => $connection->getServer()->getUserName(),
152 'SERVER_PASSWORD' => $connection->getServer()->getPassword(),
153 'SERVER_PATH' => $connection->getServer()->getBasePath(),
154 'LAST_RESULT' => $connection->getStatus(),
155 'IS_DELETED' => $connection->isDeleted() ?
'Y' :
'N',
156 'SYNCHRONIZED' => ($lastSyncTime = $connection->getLastSyncTime())
157 ? $lastSyncTime->getDate()
162 'ACCOUNT_TYPE' => $connection->getAccountType(),
163 'NEXT_SYNC_TRY' => ($nextSyncTry = $connection->getNextSyncTry())
164 ? $nextSyncTry->getDate()
174 return Sync\Connection\ConnectionMap::class;
185 Core\
Base\EntityInterface $entity,
186 array $params = [
'softDelete' =>
true]
187 ): ?Core\
Base\EntityInterface
189 if (!Loader::includeModule(
'dav'))
194 if (!empty($params[
'softDelete']))
196 $entity->setIsActive(
true);
202 $result = DavConnectionTable::delete($entity->getId());
203 if ($result->isSuccess())
205 $entity->setDeleted(
true);
225 Loader::includeModule(
'dav');
227 return DavConnectionTable::getList($params);
235 return Sync\Connection\Connection::class;