asJson) {
$this->output->writeln(json_encode($actor, JSON_PRETTY_PRINT));
}
$this->output->writeln('Account: ' . $actor->getAccount());
$this->output->writeln('Id: ' . $actor->getId());
$this->output->writeln('');
}
/**
* @param Stream[] $streams
*/
protected function outputStreams(array $streams) {
if ($this->asJson) {
$this->output->writeln(json_encode($streams, JSON_PRETTY_PRINT));
return;
}
$table = new Table($this->output);
$table->setHeaders(['Nid', 'Id', 'Source', 'Type', 'Author', 'Content']);
$table->render();
foreach ($streams as $item) {
$objectId = $item->getObjectId();
$cache = $item->getCache();
$content = '';
$author = '';
if ($objectId !== '' && $cache->hasItem($objectId)) {
try {
$cachedObject = $cache->getItem($objectId)
->getObject();
/** @var Stream $cachedItem */
$cachedItem = AP::$activityPub->getItemFromData($cachedObject);
$content = $cachedItem->getContent();
$author = $cachedItem->getActor()
->getAccount();
} catch (CacheItemNotFoundException $e) {
} catch (ItemUnknownException $e) {
} catch (RedundancyLimitException $e) {
} catch (SocialAppConfigException $e) {
}
} else {
$content = $item->getContent();
$author = $item->getActor()
->getAccount();
}
$content = ($this->crop) ? substr($content, 0, $this->crop) : $content;
$table->appendRow(
[
$item->getNid(),
'' . $item->getId() . '',
'' . $item->getActor()
->getAccount() . '',
$item->getType(),
'' . $author . '',
$content,
]
);
}
}
/**
* @param Stream $stream
*/
protected function outputStream(Stream $stream) {
$actor = $stream->getActor();
$this->output->writeln('id: ' . $stream->getId() . '');
$this->output->writeln(
'author: ' . $actor->getAccount() . ''
);
$this->output->writeln('type: ' . $stream->getType() . '');
}
}