|
|
|
@ -52,12 +52,27 @@ class ExampleContactService { |
|
|
|
|
return $folder->getFile('defaultContact.vcf')->getContent(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function setCard(?string $cardData = null) { |
|
|
|
|
private function createInitialDefaultContact(): void { |
|
|
|
|
if ($this->defaultContactExists()) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
try { |
|
|
|
|
$folder = $this->appData->getFolder('defaultContact'); |
|
|
|
|
} catch (NotFoundException $e) { |
|
|
|
|
$folder = $this->appData->newFolder('defaultContact'); |
|
|
|
|
$cardData = file_get_contents(__DIR__ . '/../ExampleContentFiles/exampleContact.vcf'); |
|
|
|
|
if (!$cardData) { |
|
|
|
|
throw new \Exception('Could not read exampleContact.vcf'); |
|
|
|
|
} |
|
|
|
|
$file = (!$folder->fileExists('defaultContact.vcf')) ? $folder->newFile('defaultContact.vcf') : $folder->getFile('defaultContact.vcf'); |
|
|
|
|
$file->putContent($cardData); |
|
|
|
|
$this->appConfig->setAppValueBool('hasCustomDefaultContact', false); |
|
|
|
|
|
|
|
|
|
} catch (\Exception $e) { |
|
|
|
|
$this->logger->error('Could not create initial default contact', ['exception' => $e]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function setCard(?string $cardData = null) { |
|
|
|
|
$folder = $this->appData->getFolder('defaultContact'); |
|
|
|
|
|
|
|
|
|
$isCustom = true; |
|
|
|
|
if (is_null($cardData)) { |
|
|
|
@ -69,7 +84,7 @@ class ExampleContactService { |
|
|
|
|
throw new \Exception('Could not read exampleContact.vcf'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$file = (!$folder->fileExists('defaultContact.vcf')) ? $folder->newFile('defaultContact.vcf') : $folder->getFile('defaultContact.vcf'); |
|
|
|
|
$file = $folder->getFile('defaultContact.vcf'); |
|
|
|
|
$file->putContent($cardData); |
|
|
|
|
|
|
|
|
|
$this->appConfig->setAppValueBool('hasCustomDefaultContact', $isCustom); |
|
|
|
@ -89,6 +104,10 @@ class ExampleContactService { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!$this->defaultContactExists()) { |
|
|
|
|
$this->createInitialDefaultContact(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
$folder = $this->appData->getFolder('defaultContact'); |
|
|
|
|
$defaultContactFile = $folder->getFile('defaultContact.vcf'); |
|
|
|
|