attachmentsManagers as $manager) { $markdown = $manager->replaceAttachmentsInMarkdown($markdown); } return $markdown; } /** * Return an instance of attachments manager for specified kind of files */ public function attachments(string $kind): AttachmentsManager { return $this->registerAttachmentsManager($kind); } /** * Register an attachments manager for specified filename */ private function registerAttachmentsManager(string $kind): AttachmentsManager { if (!array_key_exists($kind, $this->attachmentsManagers)) { $this->attachmentsManagers[$kind] = new AttachmentsManager($kind, $this); } return $this->attachmentsManagers[$kind]; } /** * Load all attachments files */ private function loadAttachments() { foreach ($this->attachmentsManagers as $manager) { $manager->load(); } } /** * Save all attachments files that needs to be */ private function saveAttachments(): bool { $oneSaved = false; foreach ($this->attachmentsManagers as $manager) { if ($manager->save()) { $oneSaved = true; } } return $oneSaved; } /** * Repair all attachments files that needs to be */ private function repairAttachments() { foreach ($this->attachmentsManagers as $manager) { $manager->repair(); } } }