ZendDbSchema
Schema management for Zend Framework
 All Classes Namespaces Functions Pages
Name.php
1 <?php
30  extends Zend_Validate_Abstract
31 {
32  const NAME_EMPTY = 'indexNameEmpty';
33  const RENAME = 'indexRename';
34 
38  protected $_messageTemplates = array(
39  self::NAME_EMPTY => "Index name can not be empty",
40  self::RENAME => "Cannot change name of existing index"
41  );
42 
49  public function isValid($value)
50  {
51  $schema = null;
52  if ($value instanceof ZendDbSchema_Db_Schema_Table_Index) {
53  $schema = $value;
54  $value = $schema->getName();
55  }
56  if (empty($value)) {
57  $this->_error(self::NAME_EMPTY);
58  return false;
59  }
60  if ($schema && $schema->isDirty('name')) {
61  if ($schema->isExist()) {
62  $this->_error(self::RENAME, $value);
63  return false;
64  }
65  }
66  return true;
67  }
68 }