Files
fdn2/app/private/lib/dao/models/PasswordRecoveryRequestModel.php
2022-08-29 23:20:16 +02:00

53 lines
1.5 KiB
PHP

<?php
/*
Author: Riccardo Di Dato
Creation Date: 17/mar/2016
*/
class PasswordRecoveryRequestModel extends Model{
public function __construct($saveableObject = null){
parent::__construct($saveableObject);
if (!$this->hasProperty("target")){
throw new CoreException("Missing parameter 'target' while calling PasswordRecoveryRequestModel::__construct()");
}
if (!array_key_exists("class", $this->target)){
throw new CoreException("Missing parameter 'target.class' while calling PasswordRecoveryRequestModel::__construct()");
}
if (!array_key_exists("id", $this->target)){
throw new CoreException("Missing parameter 'target.id' while calling PasswordRecoveryRequestModel::__construct()");
}
if (!$this->hasProperty("date")){
// $this->date = new MongoDate();
$this->date = new MongoDB\BSON\UTCDateTime( time() * 1000 );
}
if (!$this->hasProperty("sent")){
$this->sent = false;
}
}
public static function fromModel(Model $model){
$buildObj = new stdClass();
if ($model instanceof UserModel || $model instanceof AdminModel ){
$buildObj->target = array();
$buildObj->target["class"] = get_class($model);
$buildObj->target["id"] = $model->id;
return new self($buildObj);
}
else {
throw new CoreException("Impossible to build a PasswordRecoveryRequestModel from a model of class '".get_class($model)."' in PasswordRecoveryRequestModel::fromModel()");
}
}
public static function getCollectionName(){
return "passwordRecovery";
}
}
?>