TableColumns.php in Crumbs, the Breadcrumbs suite 7.2
File
lib/UI/TableColumns.php
View source
<?php
class crumbs_UI_TableColumns {
private $cols = array();
private $colGroups = array();
public function getCols() {
return $this->cols;
}
public function getColGroups() {
return $this->colGroups;
}
function addColName($colName) {
if (isset($this->cols[$colName])) {
throw new \Exception("Column '{$colName}' already exists.");
}
$this->cols[$colName] = TRUE;
}
function addColGroup($groupName, array $colNameSuffixes) {
if (empty($colNameSuffixes)) {
throw new Exception("Suffixes cannot be empty.");
}
foreach ($colNameSuffixes as $colNameSuffix) {
$colName = $groupName . '.' . $colNameSuffix;
if (isset($this->cols[$colName])) {
throw new Exception("Column '{$colName}' already exists.");
}
$this->cols[$colName] = $groupName;
}
$this->colGroups[$groupName] = $colNameSuffixes;
}
public function verifyColName($colName) {
if (1 && !isset($this->cols[$colName]) && !isset($this->colGroups[$colName]) && '' !== $colName) {
throw new Exception("Unknown column name '{$colName}'.");
}
}
}