Open Journal Systems  3.3.0
ValidatorControlledVocab.inc.php
1 <?php
2 
17 import('lib.pkp.classes.validation.Validator');
18 
21  var $_acceptedValues;
22 
29  function __construct($symbolic, $assocType, $assocId) {
30  $controlledVocabDao = DAORegistry::getDAO('ControlledVocabDAO'); /* @var $controlledVocabDao ControlledVocabDAO */
31  $controlledVocab = $controlledVocabDao->getBySymbolic($symbolic, $assocType, $assocId);
32  if ($controlledVocab) $this->_acceptedValues = array_keys($controlledVocab->enumerate());
33  else $this->_acceptedValues = array();
34  }
35 
36 
37  //
38  // Implement abstract methods from Validator
39  //
46  function isValid($value) {
47  return in_array($value, $this->_acceptedValues);
48  }
49 }
DAORegistry\getDAO
static & getDAO($name, $dbconn=null)
Definition: DAORegistry.inc.php:57
Validator
Abstract class that represents a validation check. This class and its sub-classes can be used outside...
Definition: Validator.inc.php:23
ValidatorControlledVocab\$_acceptedValues
$_acceptedValues
Definition: ValidatorControlledVocab.inc.php:24
ValidatorControlledVocab\isValid
isValid($value)
Definition: ValidatorControlledVocab.inc.php:49
ValidatorControlledVocab\__construct
__construct($symbolic, $assocType, $assocId)
Definition: ValidatorControlledVocab.inc.php:32
ValidatorControlledVocab
Validation check that checks if value is within a certain set retrieved from the database.
Definition: ValidatorControlledVocab.inc.php:19