cacheDocumentService = $cacheDocumentService; $this->cacheDocumentsRequest = $cacheDocumentsRequest; } /** * @throws InvalidOriginException */ public function activity(Acore $activity, ACore $item): void { if ($activity->getType() === Person::TYPE) { $activity->checkOrigin($item->getId()); } } public function save(ACore $item): void { /** @var Document $item */ if (!$item->isRoot()) { $item->setParentId( $item->getParent() ->getId() ); } try { $this->cacheDocumentsRequest->getById($item->getId()); $this->cacheDocumentsRequest->update($item); } catch (CacheDocumentDoesNotExistException $e) { if (!$item->isLocal()) { $this->cacheDocumentService->saveRemoteFileToCache($item); // create local copy } // parentId / url can only be empty on new document, meaning owner cannot be empty here if (($item->getUrl() === '' && $item->getParentId() === '' && $item->getAccount() !== '') || !$this->cacheDocumentsRequest->isDuplicate($item)) { $this->cacheDocumentsRequest->save($item); } } } }