86 array $optionalFilter = []
87 ): ?EO_DavConnection_Collection
89 $statement = DavConnectionTable::query()
91 ->addFilter(
'=ENTITY_TYPE', $owner->
getType())
92 ->addFilter(
'=ENTITY_ID', $owner->
getId())
93 ->addFilter(
'=ACCOUNT_TYPE', $type)
96 if (!empty($optionalFilter))
98 foreach ($optionalFilter as $key => $value)
100 $statement->addFilter($key, $value);
104 return $statement->fetchCollection() ?:
null;
118 'ENTITY_TYPE' => $connection->getOwner()->getType(),
119 'ENTITY_ID' => $connection->getOwner()->getId(),
120 'ACCOUNT_TYPE' => $connection->getVendor()->getCode(),
121 'SYNC_TOKEN' => $connection->getToken(),
122 'NAME' => $connection->getName(),
123 'SERVER_SCHEME' => $connection->getServer()->getScheme(),
124 'SERVER_HOST' => $connection->getServer()->getHost(),
125 'SERVER_PORT' => $connection->getServer()->getPort(),
126 'SERVER_USERNAME' => $connection->getServer()->getUserName(),
127 'SERVER_PASSWORD' => $connection->getServer()->getPassword(),
128 'SERVER_PATH' => $connection->getServer()->getBasePath(),
129 'MODIFIED' => $lastModified,
130 'SYNCHRONIZED' => $lastModified,
131 'LAST_RESULT' => $connection->getStatus(),
132 'IS_DELETED' => $connection->isDeleted() ?
'Y' :
'N'
134 $data = DavConnectionTable::update($connection->getId(), $fields)->getData();
135 $data[
'ID'] = $connection->getId();
137 return (
new Result())->setData($data);
141 return (
new Result())->addError(
new Error($e->getMessage()));
270 if (!Loader::includeModule(
'dav'))
272 $result->addError(
new Error(
'Module dav required'));
275 $updateResult = DavConnectionTable::update($connection->getId(), [
277 'SYNC_TOKEN' =>
null,
279 if ($updateResult->isSuccess())
283 $accountType = $connection->getAccountType() === Sync\Google\Helper::GOOGLE_ACCOUNT_TYPE_API
285 : $connection->getAccountType()
289 'delete_sync_connection',
290 $connection->getOwner()->getId(),
294 'type' => $accountType,
297 'connectionId' => $connection->getId()
303 $result->addErrors($updateResult->getErrors());