From 52ce3714cf457310ef77cde98d2d8c1676a76b51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Goetz?= Date: Tue, 7 Nov 2017 22:54:31 +0100 Subject: [PATCH] More cleanup --- libs/Format/Confluence/Api.php | 4 ++-- libs/Format/Confluence/ContentPage.php | 2 ++ libs/Format/Confluence/Publisher.php | 3 --- libs/Format/Confluence/PublisherDelete.php | 3 +++ libs/Format/HTML/Config.php | 2 +- libs/Server/Server.php | 7 ++++++- 6 files changed, 14 insertions(+), 7 deletions(-) diff --git a/libs/Format/Confluence/Api.php b/libs/Format/Confluence/Api.php index 30e8813..81d1c38 100644 --- a/libs/Format/Confluence/Api.php +++ b/libs/Format/Confluence/Api.php @@ -269,7 +269,7 @@ class Api } } - private function putAttachment($url, $id, $attachment) + private function putAttachment($url, $attachment) { $contents = array_key_exists('file', $attachment) ? fopen($attachment['file']->getPath(), 'r') : $attachment['content']; @@ -322,6 +322,6 @@ class Api $url .= "/{$result['results'][0]['id']}/data"; } - $this->putAttachment($url, $id, $attachment); + $this->putAttachment($url, $attachment); } } diff --git a/libs/Format/Confluence/ContentPage.php b/libs/Format/Confluence/ContentPage.php index ef16a86..43aa8bb 100644 --- a/libs/Format/Confluence/ContentPage.php +++ b/libs/Format/Confluence/ContentPage.php @@ -28,6 +28,8 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage } else if ($file instanceof ComputedRaw) { $filename = $file->getUri(); $this->attachments[$filename] = ['filename' => $filename, 'content' => $file->getContent()]; + } else { + throw new \RuntimeException("Cannot embed image as we don't understand its type."); } return $this->createImageTag($filename, $attributes); diff --git a/libs/Format/Confluence/Publisher.php b/libs/Format/Confluence/Publisher.php index 4f744d6..c4811d7 100644 --- a/libs/Format/Confluence/Publisher.php +++ b/libs/Format/Confluence/Publisher.php @@ -36,8 +36,6 @@ class Publisher $this->client = new Api($confluence['base_url'], $confluence['user'], $confluence['pass']); $this->client->setSpace($confluence['space_id']); - - $this->deletable = []; } public function run($title, $closure) @@ -82,7 +80,6 @@ class Publisher { if (array_key_exists('ancestor_id', $this->confluence)) { $pages = $this->client->getList($this->confluence['ancestor_id']); - $published = null; foreach ($pages as $page) { if ($page['title'] == $tree['title']) { return $page; diff --git a/libs/Format/Confluence/PublisherDelete.php b/libs/Format/Confluence/PublisherDelete.php index 5c5b593..b3a94a6 100644 --- a/libs/Format/Confluence/PublisherDelete.php +++ b/libs/Format/Confluence/PublisherDelete.php @@ -27,6 +27,9 @@ class PublisherDelete $this->output = $output; $this->delete = $delete; $this->client = $client; + + + $this->deletable = []; } protected function listDeletable($published, $prefix = '') diff --git a/libs/Format/HTML/Config.php b/libs/Format/HTML/Config.php index 7d139c3..affd476 100644 --- a/libs/Format/HTML/Config.php +++ b/libs/Format/HTML/Config.php @@ -14,7 +14,7 @@ class Config extends BaseConfig ]; } - function getEditOn() + public function getEditOn() { if (array_key_exists('edit_on', $this)) { if (is_string($this['edit_on'])) { diff --git a/libs/Server/Server.php b/libs/Server/Server.php index f154387..3702b41 100755 --- a/libs/Server/Server.php +++ b/libs/Server/Server.php @@ -18,6 +18,11 @@ class Server private $params; private $base_url; + /** + * @var Request + */ + private $request; + /** * Serve the documentation * @@ -65,7 +70,7 @@ class Server * @param string $postfix * @return string */ - function getTemporaryFile($postfix) { + private function getTemporaryFile($postfix) { $sysFileName = tempnam(sys_get_temp_dir(), 'daux'); if ($sysFileName === false) { throw new \RuntimeException("Could not create temporary file");