Skip to content

Commit

Permalink
[#13697] - Added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
niden committed Sep 7, 2019
1 parent 35082aa commit 38753f9
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion phalcon/Validation/Validator/Uniqueness.zep
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ class Uniqueness extends AbstractCombinedFieldsValidator
protected function isUniqueness(<Validation> validation, var field) -> bool
{
var values, convert, record, params, className, isModel, singleField;
/**
* @todo: The functionality below will be restored once the new Mongo related classes
* are introduced. The new classes will use the latest PHP driver.
*/
// var isDocument;

if typeof field != "array" {
Expand Down Expand Up @@ -171,23 +175,43 @@ class Uniqueness extends AbstractCombinedFieldsValidator
}

let isModel = record instanceof ModelInterface;
/**
* @todo: The functionality below will be restored once the new Mongo related classes
* are introduced. The new classes will use the latest PHP driver.
*/
// let isDocument = record instanceof CollectionInterface;

if isModel {
let params = this->isUniquenessModel(record, field, values);
/**
* @todo: The functionality below will be restored once the new Mongo related classes
* are introduced. The new classes will use the latest PHP driver.
*/
// } elseif isDocument {
// let params = this->isUniquenessCollection(record, field, values);
} else {
throw new Exception(
"The uniqueness validator works only with Phalcon\\Mvc\\Model or Phalcon\\Mvc\\Collection"
"The uniqueness validator works only with Phalcon\\Mvc\\Model"
);
/**
* @todo: The functionality below will be restored once the new Mongo related classes
* are introduced. The new classes will use the latest PHP driver.
*/
// throw new Exception(
// "The uniqueness validator works only with Phalcon\\Mvc\\Model or Phalcon\\Mvc\\Collection"
// );
}

let className = get_class(record);

return {className}::count(params) == 0;
}


/**
* @todo: The functionality below will be restored once the new Mongo related classes
* are introduced. The new classes will use the latest PHP driver.
*/
// /**
// * Uniqueness method used for collection
// */
Expand Down

0 comments on commit 38753f9

Please sign in to comment.