/** * * @param stdClass $pPhpObject * @return ComplexLoadRequest */ public static function buildObjectLoadRequest($pPhpObject) { if (isset($pPhpObject->model)) { $lObjectLoadRequest = new ComplexLoadRequest($pPhpObject->model); } else { if (isset($pPhpObject->tree) && isset($pPhpObject->tree->model)) { $lObjectLoadRequest = new ComplexLoadRequest($pPhpObject->tree->model); $lObjectLoadRequest->importModelTree($pPhpObject->tree); } else { throw new Exception("request doesn't have model"); } } if (isset($pPhpObject->logicalJunction) && isset($pPhpObject->literal)) { throw new Exception('can\'t have logicalJunction and literal properties in same time'); } if (isset($pPhpObject->literalCollection)) { $lObjectLoadRequest->importLiteralCollection($pPhpObject->literalCollection); } if (isset($pPhpObject->logicalJunction)) { $lObjectLoadRequest->importLogicalJunction($pPhpObject->logicalJunction); } else { if (isset($pPhpObject->literal)) { $lObjectLoadRequest->importLiteral($pPhpObject->literal); } } if (isset($pPhpObject->maxLength)) { $lObjectLoadRequest->setMaxLength($pPhpObject->maxLength); } if (isset($pPhpObject->offset)) { $lObjectLoadRequest->setOffset($pPhpObject->offset); } if (isset($pPhpObject->order)) { if (!is_array($pPhpObject->order)) { throw new Exception("order parameter must be an array"); } foreach ($pPhpObject->order as $lOrder) { if (!isset($lOrder->property)) { throw new Exception("an order element doesn't have property"); } $lObjectLoadRequest->addOrder($lOrder->property, isset($lOrder->type) ? $lOrder->type : SelectQuery::ASC); } } if (isset($pPhpObject->requestChildren)) { $lObjectLoadRequest->requestChildren($pPhpObject->requestChildren); } if (isset($pPhpObject->loadForeignProperties)) { $lObjectLoadRequest->loadForeignProperties($pPhpObject->loadForeignProperties); } return $lObjectLoadRequest; }