Пример #1
0
 function validateAgainst(\Tracker\Tabular\Schema $schema)
 {
     if ($this->isPrimary && $this->isReadOnly) {
         throw new \Exception(tr('Primary Key fields cannot be read-only.'));
     }
     $selfCount = 0;
     foreach ($schema->getColumns() as $column) {
         if ($column->is($this->permName, $this->mode)) {
             $selfCount++;
         }
         foreach ($this->incompatibilities as $entry) {
             list($field, $mode) = $entry;
             if ($column->is($field, $mode)) {
                 // Skip incompatibility if either field is read-only
                 if ($this->isReadOnly() || $column->isReadOnly()) {
                     continue;
                 }
                 throw new \Exception(tr('Column "%0" cannot co-exist with "%1".', $column->getEncodedHeader(), $this->getEncodedHeader()));
             }
         }
     }
     if ($selfCount > 1) {
         throw new \Exception(tr('Column "%0:%1" found multiple times.', $this->permName, $this->mode));
     }
 }