/**
* Constructor
*
* @param AbstractEntity $entity The target
* @param string $field The field name
*/
public function __construct(AbstractEntity $entity, $field)
{
$this->entity = $entity;
if (!$entity instanceof AbstractEntity) {
throw new \InvalidArgumentException("The first argument should be instance of the AbstractEntity class.");
}
$this->field = $this->entity->getIterator()->getField($field);
if (!$this->field) {
throw new ModelException(sprintf("Invalid field %s for entity %s", $field, get_class($this->entity)));
}
}