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"; } } ?>