|
Revision 16964, 1.4 kB
(checked in by Jonathan.Wage, 4 years ago)
|
[1.2, 1.3] sfDoctrinePlugin: fixing sfValidatorDoctrineChoiceMany and reverting change to make it equal to Propel (closes #4511)
|
| Line | |
|---|
| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
class sfValidatorDoctrineChoiceMany extends sfValidatorDoctrineChoice |
|---|
| 22 |
{ |
|---|
| 23 |
|
|---|
| 24 |
* @see sfValidatorBase |
|---|
| 25 |
*/ |
|---|
| 26 |
protected function doClean($values) |
|---|
| 27 |
{ |
|---|
| 28 |
if (!is_array($values)) |
|---|
| 29 |
{ |
|---|
| 30 |
$values = array($values); |
|---|
| 31 |
} |
|---|
| 32 |
|
|---|
| 33 |
if(isset($values[0]) && !$values[0]) |
|---|
| 34 |
{ |
|---|
| 35 |
unset($values[0]); |
|---|
| 36 |
} |
|---|
| 37 |
|
|---|
| 38 |
$a = $this->getOption('alias'); |
|---|
| 39 |
$q = is_null($this->getOption('query')) ? Doctrine_Query::create()->from($this->getOption('model') . ' ' . $a) : $this->getOption('query'); |
|---|
| 40 |
$q = $q->andWhereIn($a . '.' . $this->getColumn(), $values); |
|---|
| 41 |
|
|---|
| 42 |
$objects = $q->execute(); |
|---|
| 43 |
|
|---|
| 44 |
if (count($objects) != count($values)) |
|---|
| 45 |
{ |
|---|
| 46 |
throw new sfValidatorError($this, 'invalid', array('value' => $values)); |
|---|
| 47 |
} |
|---|
| 48 |
|
|---|
| 49 |
return $values; |
|---|
| 50 |
} |
|---|
| 51 |
} |
|---|
| 52 |
|
|---|