Permalink
Browse files

Removed validation. Fixes #94

  • Loading branch information...
1 parent 93217aa commit ca496b2f41ca7209c5c9ae6f2c6a5b966875a170 @willdurand willdurand committed Dec 16, 2011
Showing with 11 additions and 2,654 deletions.
  1. +0 −6 src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehavior.php
  2. +0 −5 src/Propel/Generator/Behavior/I18n/I18nBehavior.php
  3. +0 −9 src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php
  4. +2 −3 src/Propel/Generator/Builder/Om/AbstractPeerBuilder.php
  5. +0 −193 src/Propel/Generator/Builder/Om/ObjectBuilder.php
  6. +0 −58 src/Propel/Generator/Builder/Om/PeerBuilder.php
  7. +1 −19 src/Propel/Generator/Builder/Om/TableMapBuilder.php
  8. +0 −13 src/Propel/Generator/Builder/Util/XmlToAppData.php
  9. +3 −11 src/Propel/Generator/Model/Column.php
  10. +0 −21 src/Propel/Generator/Model/Database.php
  11. +0 −193 src/Propel/Generator/Model/Rule.php
  12. +1 −69 src/Propel/Generator/Model/Table.php
  13. +0 −183 src/Propel/Generator/Model/Validator.php
  14. +0 −289 src/Propel/Generator/Task/PropelSchemaReverseTask.php
  15. +0 −22 src/Propel/Runtime/Map/ColumnMap.php
  16. +0 −26 src/Propel/Runtime/Map/TableMap.php
  17. +0 −106 src/Propel/Runtime/Map/ValidatorMap.php
  18. +0 −57 src/Propel/Runtime/Util/BasePeer.php
  19. +0 −35 src/Propel/Runtime/Validator/BasicValidator.php
  20. +0 −76 src/Propel/Runtime/Validator/MatchValidator.php
  21. +0 −48 src/Propel/Runtime/Validator/MaxLengthValidator.php
  22. +0 −49 src/Propel/Runtime/Validator/MaxValueValidator.php
  23. +0 −44 src/Propel/Runtime/Validator/MinLengthValidator.php
  24. +0 −49 src/Propel/Runtime/Validator/MinValueValidator.php
  25. +0 −74 src/Propel/Runtime/Validator/NotMatchValidator.php
  26. +0 −44 src/Propel/Runtime/Validator/RequiredValidator.php
  27. +0 −78 src/Propel/Runtime/Validator/TypeValidator.php
  28. +0 −55 src/Propel/Runtime/Validator/UniqueValidator.php
  29. +0 −42 src/Propel/Runtime/Validator/ValidValuesValidator.php
  30. +0 −123 src/Propel/Runtime/Validator/ValidationFailed.php
  31. +0 −3 tests/Fixtures/bookstore/behavior-concrete-inheritance-schema.xml
  32. +0 −27 tests/Fixtures/bookstore/schema.xml
  33. +0 −18 tests/Fixtures/namespaced/schema.xml
  34. +0 −11 tests/Fixtures/schemas/schema.xml
  35. +0 −142 tests/Propel/Tests/BookstoreTest.php
  36. +0 −6 tests/Propel/Tests/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehaviorTest.php
  37. +0 −50 tests/Propel/Tests/Generator/Behavior/I18n/I18nBehaviorTest.php
  38. +0 −12 tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTest.php
  39. +3 −3 tests/Propel/Tests/Generator/Builder/Util/XmlToAppDataTest.php
  40. +0 −33 tests/Propel/Tests/Generator/Model/ColumnTest.php
  41. +0 −22 tests/Propel/Tests/Generator/Model/TableTest.php
  42. +0 −32 tests/Propel/Tests/Helpers/Bookstore/Validator/ISBNValidator.php
  43. +0 −239 tests/Propel/Tests/Runtime/Validator/ValidatorTest.php
  44. +0 −15 tools/generator/build.properties-sample
  45. +0 −2 tools/generator/default.properties
  46. +1 −16 tools/generator/resources/dtd/database.dtd
  47. +0 −23 tools/generator/resources/xsl/database.xsl
@@ -83,12 +83,6 @@ public function modifyTable()
$this->getTable()->addForeignKey($copiedFk);
}
- // add the validators of the parent table
- foreach ($parentTable->getValidators() as $validator) {
- $copiedValidator = clone $validator;
- $this->getTable()->addValidator($copiedValidator);
- }
-
// add the indices of the parent table
foreach ($parentTable->getIndices() as $index) {
$copiedIndex = clone $index;
@@ -142,15 +142,10 @@ protected function moveI18nColumns()
$column = $table->getColumn($columnName);
// add the column
$i18nColumn = $i18nTable->addColumn(clone $column);
- // add related validators
- if ($validator = $column->getValidator()) {
- $i18nValidator = $i18nTable->addValidator(clone $validator);
- }
// FIXME: also move FKs, and indices on this column
}
if ($table->hasColumn($columnName)) {
$table->removeColumn($columnName);
- $table->removeValidatorForColumn($columnName);
}
}
}
@@ -162,15 +162,6 @@ protected function isAddGenericAccessors()
return (!$table->isAlias() && $this->getBuildProperty('addGenericAccessors'));
}
- /**
- * Whether to add the validate() method.
- * This is based on the build property propel.addValidateMethod
- */
- protected function isAddValidateMethod()
- {
- return $this->getBuildProperty('addValidateMethod');
- }
-
protected function hasDefaultValues()
{
foreach ($this->getTable()->getColumns() as $col) {
@@ -90,7 +90,7 @@ protected function addGetOMClassMethod(&$script)
}
/**
- * Adds the doInsert(), doUpdate(), doDeleteAll(), doValidate(), etc. methods.
+ * Adds the doInsert(), doUpdate(), doDeleteAll(), etc. methods.
* @param string &$script The script will be modified in this method.
*/
protected function addUpdateMethods(&$script)
@@ -105,7 +105,6 @@ protected function addUpdateMethods(&$script)
if ($this->isDeleteSetNullEmulationNeeded()) {
$this->addDoOnDeleteSetNull($script);
}
- $this->addDoValidate($script);
}
/**
@@ -160,7 +159,7 @@ protected function addClassBody(&$script)
$this->addGetOMClassMethod($script);
- // add the insert, update, delete, validate etc. methods
+ // add the insert, update, delete, etc. methods
if (!$table->isAlias() && !$table->isReadOnly()) {
$this->addUpdateMethods($script);
}
@@ -272,10 +272,6 @@ protected function addClassBody(&$script)
$this->addManipulationMethods($script);
}
- if ($this->isAddValidateMethod()) {
- $this->addValidationMethods($script);
- }
-
if ($this->isAddGenericAccessors()) {
$this->addGetByName($script);
$this->addGetByPosition($script);
@@ -376,7 +372,6 @@ protected function addAttributes(&$script)
}
$this->addAlreadyInSaveAttribute($script);
- $this->addAlreadyInValidationAttribute($script);
// apply behaviors
$this->applyBehaviorModifier('objectAttributes', $script, " ");
@@ -2623,54 +2618,6 @@ protected function addManipulationMethods(&$script)
}
/**
- * Adds the methods related to validationg the object.
- * @param string &$script The script will be modified in this method.
- */
- protected function addValidationMethods(&$script)
- {
- $this->addValidationFailuresAttribute($script);
- $this->addGetValidationFailures($script);
- $this->addValidate($script);
- $this->addDoValidate($script);
- }
-
- /**
- * Adds the $validationFailures attribute to store ValidationFailed objects.
- * @param string &$script The script will be modified in this method.
- */
- protected function addValidationFailuresAttribute(&$script)
- {
- $script .= "
- /**
- * Array of ValidationFailed objects.
- * @var array ValidationFailed[]
- */
- protected \$validationFailures = array();
-";
- }
-
- /**
- * Adds the getValidationFailures() method.
- * @param string &$script The script will be modified in this method.
- */
- protected function addGetValidationFailures(&$script)
- {
- $script .= "
- /**
- * Gets any ValidationFailed objects that resulted from last call to validate().
- *
- *
- * @return array ValidationFailed[]
- * @see validate()
- */
- public function getValidationFailures()
- {
- return \$this->validationFailures;
- }
-";
- } // addGetValidationFailures()
-
- /**
* Adds the correct getPrimaryKey() method for this object.
* @param string &$script The script will be modified in this method.
*/
@@ -4717,145 +4664,6 @@ protected function addSaveClose(&$script) {
}
/**
- * Adds the $alreadyInValidation attribute, which prevents attempting to re-validate the same object.
- * @param string &$script The script will be modified in this method.
- */
- protected function addAlreadyInValidationAttribute(&$script)
- {
- $script .= "
- /**
- * Flag to prevent endless validation loop, if this object is referenced
- * by another object which falls in this transaction.
- * @var boolean
- */
- protected \$alreadyInValidation = false;
-";
- }
-
- /**
- * Adds the validate() method.
- * @param string &$script The script will be modified in this method.
- */
- protected function addValidate(&$script)
- {
- $script .= "
- /**
- * Validates the objects modified field values and all objects related to this table.
- *
- * If \$columns is either a column name or an array of column names
- * only those columns are validated.
- *
- * @param mixed \$columns Column name or an array of column names.
- * @return boolean Whether all columns pass validation.
- * @see doValidate()
- * @see getValidationFailures()
- */
- public function validate(\$columns = null)
- {
- \$res = \$this->doValidate(\$columns);
- if (\$res === true) {
- \$this->validationFailures = array();
-
- return true;
- } else {
- \$this->validationFailures = \$res;
-
- return false;
- }
- }
-";
- } // addValidate()
-
- /**
- * Adds the workhourse doValidate() method.
- * @param string &$script The script will be modified in this method.
- */
- protected function addDoValidate(&$script)
- {
- $table = $this->getTable();
-
- $script .= "
- /**
- * This function performs the validation work for complex object models.
- *
- * In addition to checking the current object, all related objects will
- * also be validated. If all pass then <code>true</code> is returned; otherwise
- * an aggreagated array of ValidationFailed objects will be returned.
- *
- * @param array \$columns Array of column names to validate.
- * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
- */
- protected function doValidate(\$columns = null)
- {
- if (!\$this->alreadyInValidation) {
- \$this->alreadyInValidation = true;
- \$retval = null;
-
- \$failureMap = array();
-";
- if (count($table->getForeignKeys()) != 0) {
- $script .= "
-
- // We call the validate method on the following object(s) if they
- // were passed to this object by their coresponding set
- // method. This object relates to these object(s) by a
- // foreign key reference.
-";
- foreach ($table->getForeignKeys() as $fk) {
- $aVarName = $this->getFKVarName($fk);
- $script .= "
- if (\$this->".$aVarName." !== null) {
- if (!\$this->".$aVarName."->validate(\$columns)) {
- \$failureMap = array_merge(\$failureMap, \$this->".$aVarName."->getValidationFailures());
- }
- }
-";
- } /* for () */
- } /* if count(fkeys) */
-
- $script .= "
-
- if ((\$retval = ".$this->getPeerClassname()."::doValidate(\$this, \$columns)) !== true) {
- \$failureMap = array_merge(\$failureMap, \$retval);
- }
-
-";
-
- foreach ($table->getReferrers() as $refFK) {
- if ($refFK->isLocalPrimaryKey()) {
- $varName = $this->getPKRefFKVarName($refFK);
- $script .= "
- if (\$this->$varName !== null) {
- if (!\$this->".$varName."->validate(\$columns)) {
- \$failureMap = array_merge(\$failureMap, \$this->".$varName."->getValidationFailures());
- }
- }
-";
- } else {
- $collName = $this->getRefFKCollVarName($refFK);
- $script .= "
- if (\$this->$collName !== null) {
- foreach (\$this->$collName as \$referrerFK) {
- if (!\$referrerFK->validate(\$columns)) {
- \$failureMap = array_merge(\$failureMap, \$referrerFK->getValidationFailures());
- }
- }
- }
-";
- }
- } /* foreach getReferrers() */
-
- $script .= "
-
- \$this->alreadyInValidation = false;
- }
-
- return (!empty(\$failureMap) ? \$failureMap : true);
- }
-";
- } // addDoValidate()
-
- /**
* Adds the ensureConsistency() method to ensure that internal state is correct.
* @param string &$script The script will be modified in this method.
*/
@@ -5065,7 +4873,6 @@ public function clear()
$script .= "
\$this->alreadyInSave = false;
- \$this->alreadyInValidation = false;
\$this->clearAllReferences();";
if ($this->hasDefaultValues()) {
@@ -1817,64 +1817,6 @@ protected static function doOnDeleteSetNull(Criteria \$criteria, ConnectionInter
}
/**
- * Adds the doValidate() method.
- * @param string &$script The script will be modified in this method.
- */
- protected function addDoValidate(&$script)
- {
- $table = $this->getTable();
- $script .= "
- /**
- * Validates all modified columns of given ".$this->getObjectClassname()." object.
- * If parameter \$columns is either a single column name or an array of column names
- * than only those columns are validated.
- *
- * NOTICE: This does not apply to primary or foreign keys for now.
- *
- * @param ".$this->getObjectClassname()." \$obj The object to validate.
- * @param mixed \$cols Column name or array of column names.
- *
- * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
- */
- public static function doValidate(\$obj, \$cols = null)
- {
- \$columns = array();
-
- if (\$cols) {
- \$dbMap = Propel::getServiceContainer()->getDatabaseMap(".$this->getPeerClassname()."::DATABASE_NAME);
- \$tableMap = \$dbMap->getTable(".$this->getPeerClassname()."::TABLE_NAME);
-
- if (! is_array(\$cols)) {
- \$cols = array(\$cols);
- }
-
- foreach (\$cols as \$colName) {
- if (\$tableMap->hasColumn(\$colName)) {
- \$get = 'get' . \$tableMap->getColumn(\$colName)->getPhpName();
- \$columns[\$colName] = \$obj->\$get();
- }
- }
- } else {
-";
- foreach ($table->getValidators() as $val) {
- $col = $val->getColumn();
- if (!$col->isAutoIncrement()) {
- $script .= "
- if (\$obj->isNew() || \$obj->isColumnModified(".$this->getColumnConstant($col)."))
- \$columns[".$this->getColumnConstant($col)."] = \$obj->get".$col->getPhpName()."();
-";
- } // if
- } // foreach
-
- $script .= "
- }
-
- return {$this->basePeerClassname}::doValidate(".$this->getPeerClassname()."::DATABASE_NAME, ".$this->getPeerClassname()."::TABLE_NAME, \$columns);
- }
-";
- } // end addDoValidate()
-
- /**
* Adds the retrieveByPK method for tables with single-column primary key.
* @param string &$script The script will be modified in this method.
*/
Oops, something went wrong. Retry.

0 comments on commit ca496b2

Please sign in to comment.