/** * Adds the given EntityRevision to the API result. * * @param string|null $sourceEntityId * @param EntityRevision|null $entityRevision * @param array $params */ private function handleEntity($sourceEntityId, EntityRevision $entityRevision = null, array $params = array()) { if ($entityRevision === null) { $this->resultBuilder->addMissingEntity($sourceEntityId, array('id' => $sourceEntityId)); } else { list($languageCodeFilter, $fallbackChains) = $this->getLanguageCodesAndFallback($params); $this->resultBuilder->addEntityRevision($sourceEntityId, $entityRevision, $this->getPropsFromParams($params), $params['sitefilter'], $languageCodeFilter, $fallbackChains); } }
/** * Pushes the given $entity into the ApiResult held by the ApiMain module * returned by newApiMain(). Calling $printer->execute() later will output this * result, if $printer was generated from that same ApiMain module, as * createApiPrinter() does. * * @param EntityRevision $entityRevision The entity to convert ot an ApiResult * @param ApiFormatBase $printer The output printer that will be used for serialization. * Used to provide context for generating the ApiResult, and may also be manipulated * to fine-tune the output. * * @return ApiResult */ private function generateApiResult(EntityRevision $entityRevision, ApiFormatBase $printer) { $res = $printer->getResult(); // Make sure result is empty. May still be full if this // function gets called multiple times during testing, etc. $res->reset(); $resultBuilder = new ResultBuilder($res, $this->entityTitleLookup, $this->serializerFactory, $this->siteStore, $this->propertyLookup, false); $resultBuilder->addEntityRevision(null, $entityRevision); return $res; }