/**
* @param object $object The link object
*
* @return self
*
* @throws ValidationException
*/
public function __construct($object, FactoryManagerInterface $manager)
{
if (!is_object($object)) {
throw new ValidationException('RelationshipLink has to be an object, "' . gettype($object) . '" given.');
}
if (!property_exists($object, 'self') and !property_exists($object, 'related')) {
throw new ValidationException('RelationshipLink has to be at least a "self" or "related" link');
}
$this->manager = $manager;
$this->container = new DataContainer();
if (property_exists($object, 'self')) {
if (!is_string($object->self)) {
throw new ValidationException('property "self" has to be a string, "' . gettype($object->self) . '" given.');
}
$this->container->set('self', strval($object->self));
}
if (property_exists($object, 'related')) {
if (!is_string($object->related)) {
throw new ValidationException('property "related" has to be a string, "' . gettype($object->related) . '" given.');
}
$this->container->set('related', strval($object->related));
}
if (property_exists($object, 'pagination')) {
$this->container->set('pagination', $this->manager->getFactory()->make('Pagination', [$object->pagination, $this->manager]));
}
}