1 installer_test.module | installer_test_get_results($filters) |
Returns projects based on the filters.
File
- core/
modules/ installer/ tests/ installer_test/ installer_test.module, line 88
Code
function installer_test_get_results($filters) {
$projects = installer_test_projects();
$results = array(
'total' => count($projects),
'projects' => array(),
);
// Filter out projects based on type
if (isset($filters['type']) && $type = $filters['type']) {
foreach ($projects as $name => $project) {
if ($type != $project['type']) {
unset($projects[$name]);
}
}
}
// Filter out projects based on backdrop version number
if (isset($filters['version']) && $version = $filters['version']) {
foreach ($projects as $name => $project) {
if ($version != $project['version']) {
unset($projects[$name]);
}
}
}
// Filter out projects based on the text query
if (isset($filters['text']) && $text = $filters['text']) {
foreach ($projects as $name => $project) {
if (!stristr($project['title'], $text) && !stristr($project['description'], $text)) {
unset($projects[$name]);
}
}
}
$results['total'] = count($projects);
// Only send back the requested amount
$start = $filters['page'] * $filters['items_per_page'];
$end = $start + $filters['items_per_page'];
$results['projects'] = $projects;
return $results;
}