public function RestfulDataProviderCToolsPlugins::getPluginsSortedAndFiltered in RESTful 7
Gets the plugins filtered and sorted by the request.
Return value
array Array of plugins.
2 calls to RestfulDataProviderCToolsPlugins::getPluginsSortedAndFiltered()
- RestfulDataProviderCToolsPlugins::getTotalCount in plugins/
restful/ RestfulDataProviderCToolsPlugins.php - Get the total count of entities that match certain request.
- RestfulDataProviderCToolsPlugins::index in plugins/
restful/ RestfulDataProviderCToolsPlugins.php - Get a list of entities.
File
- plugins/
restful/ RestfulDataProviderCToolsPlugins.php, line 69 - Contains \RestfulDataProviderCToolsPlugins
Class
Code
public function getPluginsSortedAndFiltered() {
$plugins = $this
->getPlugins();
$public_fields = $this
->getPublicFields();
foreach ($this
->parseRequestForListFilter() as $filter) {
foreach ($plugins as $plugin_name => $plugin) {
// Initialize to TRUE for AND and FALSE for OR (neutral value).
$match = $filter['conjunction'] == 'AND';
for ($index = 0; $index < count($filter['value']); $index++) {
$property = $public_fields[$filter['public_field']]['property'];
if (empty($plugin[$property])) {
// Property doesn't exist on the plugin, so filter it out.
unset($plugins[$plugin_name]);
}
if ($filter['conjunction'] == 'OR') {
$match = $match || $this
->evaluateExpression($plugin[$property], $filter['value'][$index], $filter['operator'][$index]);
if ($match) {
break;
}
}
else {
$match = $match && $this
->evaluateExpression($plugin[$property], $filter['value'][$index], $filter['operator'][$index]);
if (!$match) {
break;
}
}
}
if (!$match) {
// Property doesn't match the filter.
unset($plugins[$plugin_name]);
}
}
}
if ($this
->parseRequestForListSort()) {
uasort($plugins, array(
$this,
'sortMultiCompare',
));
}
return $plugins;
}