public function getObject() { // force json format $this->getResponse()->setFormat('json'); $id = $this->request->getVal('id', false); $url = $this->request->getVal('url', false); $object = null; if (!empty($id)) { $object = $this->structuredData->getSDElementById($id); } else { if (!empty($url)) { $object = $this->structuredData->getSDElementByURL($url); } } if (is_object($object)) { $this->response->setBody((string) $object); } }
public function expandValue(StructuredData $structuredData, $elementDepth) { $value = $this->value; if (is_object($value) && isset($value->id)) { $value = array($value); } if (is_array($value)) { foreach ($value as $v) { if (isset($v->id)) { try { $SDElement = $structuredData->getSDElementById($v->id, $elementDepth + 1); $v->object = $SDElement; } catch (WikiaException $e) { $v->object = null; } } } } }