/**
* Utility function. Gets row count of a set of tables grouped by the 'name' column.
* This is the implementation of the getRowCountsAndSizeBy... functions.
*/
private function getRowCountsByArchiveName($statuses, $getRowSizeMethod, $forceCache = false, $otherSelects = array(), $otherDataTableColumns = array())
{
$extraCols = '';
if (!empty($otherSelects)) {
$extraCols = ', ' . implode(', ', $otherSelects);
}
$cols = array_merge(array('row_count'), $otherDataTableColumns);
$dataTable = new DataTable();
foreach ($statuses as $status) {
$dataTableOptionName = $this->getCachedOptionName($status['Name'], 'byArchiveName');
// if option exists && !$forceCache, use the cached data, otherwise create the
$cachedData = Option::get($dataTableOptionName);
if ($cachedData !== false && !$forceCache) {
$table = DataTable::fromSerializedArray($cachedData);
} else {
$table = new DataTable();
$table->addRowsFromSimpleArray($this->dataAccess->getRowCountsByArchiveName($status['Name'], $extraCols));
$reduceArchiveRowName = array($this, 'reduceArchiveRowName');
$table->filter('GroupBy', array('label', $reduceArchiveRowName));
$serializedTables = $table->getSerialized();
$serializedTable = reset($serializedTables);
Option::set($dataTableOptionName, $serializedTable);
}
// add estimated_size column
$getEstimatedSize = array($this, $getRowSizeMethod);
$table->filter('ColumnCallbackAddColumn', array($cols, 'estimated_size', $getEstimatedSize, array($status)));
$dataTable->addDataTable($table);
}
return $dataTable;
}