Development

/branches/1.1/lib/plugins/sfPropelPlugin/lib/propel/validator/sfValidatorPropelChoiceMany.class.php

You must first sign up to be able to contribute.

root/branches/1.1/lib/plugins/sfPropelPlugin/lib/propel/validator/sfValidatorPropelChoiceMany.class.php

Revision 15627, 1.2 kB (checked in by Kris.Wallsmith, 6 years ago)

[1.1, 1.2, 1.3] fixed sfValidatorPropelChoice(Many) overrides some Criteria (closes #5924)

  • Property svn:mime-type set to text/x-php
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1 <?php
2
3 /*
4  * This file is part of the symfony package.
5  * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 /**
12  * sfValidatorPropelChoiceMany validates than an array of values is in the array of the existing rows of a table.
13  *
14  * @package    symfony
15  * @subpackage validator
16  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
17  * @version    SVN: $Id$
18  */
19 class sfValidatorPropelChoiceMany extends sfValidatorPropelChoice
20 {
21   /**
22    * @see sfValidatorBase
23    */
24   protected function doClean($values)
25   {
26     if (!is_array($values))
27     {
28       $values = array($values);
29     }
30
31     $criteria = is_null($this->getOption('criteria')) ? new Criteria() : clone $this->getOption('criteria');
32     $criteria->addAnd($this->getColumn(), $values, Criteria::IN);
33
34     $objects = call_user_func(array($this->getOption('model').'Peer', 'doSelect'), $criteria, $this->getOption('connection'));
35
36     if (count($objects) != count($values))
37     {
38       throw new sfValidatorError($this, 'invalid', array('value' => $values));
39     }
40
41     return $values;
42   }
43 }
44
Note: See TracBrowser for help on using the browser.