diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2018-07-28 22:48:21 +0300 |
---|---|---|
committer | Maxence Lange <maxence@artificial-owl.com> | 2018-07-28 22:48:21 +0300 |
commit | 82c568b65649187ba747046d23e40558b30fce8e (patch) | |
tree | d17d0076ee125374e51f3cd033dcad6fdcd4fee4 /lib | |
parent | fb4362d02d416d32eb46030b2140af91c8c12dd4 (diff) |
fix result display
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Command/DocumentProvider.php | 27 | ||||
-rw-r--r-- | lib/Model/IndexDocument.php | 1 |
2 files changed, 18 insertions, 10 deletions
diff --git a/lib/Command/DocumentProvider.php b/lib/Command/DocumentProvider.php index db3999a..c672f81 100644 --- a/lib/Command/DocumentProvider.php +++ b/lib/Command/DocumentProvider.php @@ -95,18 +95,25 @@ class DocumentProvider extends ExtendedBase { $index->setOwnerId($userId); $index->setStatus(Index::INDEX_FULL); $indexDocument = $provider->updateDocument($index); - $result = [ - 'document' => $indexDocument - ]; - if ($input->getOption('content') === true) { - $content = $indexDocument->getContent(); - if ($indexDocument->isContentEncoded() === IndexDocument::ENCODED_BASE64) { - $content = base64_decode($content); - } - $result['content'] = substr($content, 0, 200); + if ($indexDocument->getIndex() + ->isStatus(Index::INDEX_REMOVE)) { + throw new Exception('Unknown document'); } + + $output->writeln('Document: '); + $output->writeln(json_encode($indexDocument, JSON_PRETTY_PRINT)); - $output->writeln(json_encode($result, JSON_PRETTY_PRINT)); + if ($input->getOption('content') !== true) { + return; + } + + $output->writeln('Content: '); + $content = $indexDocument->getContent(); + if ($indexDocument->isContentEncoded() === IndexDocument::ENCODED_BASE64) { + $content = base64_decode($content, true); + } + + $output->writeln(substr($content, 0, 60)); } diff --git a/lib/Model/IndexDocument.php b/lib/Model/IndexDocument.php index 3fa45c9..92bb7d5 100644 --- a/lib/Model/IndexDocument.php +++ b/lib/Model/IndexDocument.php @@ -532,6 +532,7 @@ class IndexDocument implements \JsonSerializable { 'modifiedTime' => $this->getModifiedTime(), 'title' => $this->getTitle(), 'link' => $this->getLink(), + 'index' => $this->getIndex(), 'source' => $this->getSource(), 'info' => $this->getInfoAll(), 'hash' => $this->getHash(), |