private function getSerialized(Item $item) { $serialization = array('type' => $item->getType()); $this->addIdToSerialization($item, $serialization); $this->addTermsToSerialization($item, $serialization); $this->addStatementListToSerialization($item, $serialization); $this->addSiteLinksToSerialization($item, $serialization); return $serialization; }
/** * Throws an exception if it would not be possible to save the updated items * @throws ChangeOpException */ private function applyConstraintChecks(Item $item, ItemId $fromId) { $constraintValidator = new CompositeEntityValidator($this->constraintProvider->getUpdateValidators($item->getType())); $result = $constraintValidator->validateEntity($item); $errors = $result->getErrors(); $errors = $this->removeConflictsWithEntity($errors, $fromId); if (!empty($errors)) { $result = Result::newError($errors); throw new ChangeOpValidationException($result); } }
/** * @param Item|Property $entity * * @throws RuntimeException * @return ItemContent|PropertyContent * @todo this could be factored into a different class? */ private function getContentFromEntity($entity) { switch ($entity->getType()) { case Item::ENTITY_TYPE: return new ItemContent($entity); case Property::ENTITY_TYPE: return new PropertyContent($entity); default: throw new RuntimeException('I cant get a content for this type of entity'); } }