public function getDataByIdAction()
{
// check for lock
if (Element\Editlock::isLocked($this->getParam("id"), "document")) {
$this->_helper->json(["editlock" => Element\Editlock::getByElement($this->getParam("id"), "document")]);
}
Element\Editlock::lock($this->getParam("id"), "document");
$snippet = Document\Snippet::getById($this->getParam("id"));
$snippet = clone $snippet;
$snippet = $this->getLatestVersion($snippet);
$versions = Element\Service::getSafeVersionInfo($snippet->getVersions());
$snippet->setVersions(array_splice($versions, 0, 1));
$snippet->getScheduledTasks();
$snippet->idPath = Element\Service::getIdPath($snippet);
$snippet->userPermissions = $snippet->getUserPermissions();
$snippet->setLocked($snippet->isLocked());
$snippet->setParent(null);
if ($snippet->getContentMasterDocument()) {
$snippet->contentMasterDocumentPath = $snippet->getContentMasterDocument()->getRealFullPath();
}
$this->addTranslationsData($snippet);
$this->minimizeProperties($snippet);
// unset useless data
$snippet->setElements(null);
//Hook for modifying return value - e.g. for changing permissions based on object data
//data need to wrapped into a container in order to pass parameter to event listeners by reference so that they can change the values
$returnValueContainer = new \Pimcore\Model\Tool\Admin\EventDataContainer(object2array($snippet));
\Pimcore::getEventManager()->trigger("admin.document.get.preSendData", $this, ["document" => $snippet, "returnValueContainer" => $returnValueContainer]);
if ($snippet->isAllowed("view")) {
$this->_helper->json($returnValueContainer->getData());
}
$this->_helper->json(false);
}