Skip to content

Instantly share code, notes, and snippets.

@oojacoboo
Created December 16, 2012 05:23
Show Gist options
  • Save oojacoboo/4303550 to your computer and use it in GitHub Desktop.
Save oojacoboo/4303550 to your computer and use it in GitHub Desktop.
$json['title'] = "Documents JSON";
$json['description'] = "All the documents per company";
$json['generator'] = "https://xxxxx.com/";
$json['documents'] = array();
foreach($docs as $doc) {
Debug::toLog($doc->getId());
$json['documents'][$doc->getId()]['id'] = $doc->getId();
$json['documents'][$doc->getId()]['groupId'] = $doc->getDocumentGroupId();
$json['documents'][$doc->getId()]['groupName'] = $doc->getDocumentGroup()->getName();
$json['documents'][$doc->getId()]['updatedAt'] = $this->getUser()->getProfile()->toUserTimezone($doc->getUpdatedAt("U"), "M. j, Y");
$json['documents'][$doc->getId()]['nickname'] = $doc->getNickname();
$json['documents'][$doc->getId()]['filesize'] = $doc->getFilesize();
$json['documents'][$doc->getId()]['icon'] = $doc->getIcon("small");
}
$json['docGroups'] = array();
foreach($docGroups as $docGroup) {
$json['docGroups'][$docGroup->getId()]['id'] = $docGroup->getId();
$json['docGroups'][$docGroup->getId()]['name'] = $docGroup->getName();
}
return $this->renderText(json_encode($json));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment