Newscoop\Service\Implementation\ThemeServiceLocalFileSystem::filterThemes PHP Method

filterThemes() protected method

Filters the provided array of themes based on the search.
protected filterThemes ( SearchTheme $search, array $themes ) : array
$search Newscoop\Service\Model\SearchTheme The search to filter the themes by, *(not null not empty).
$themes array The array of Theme objects to be filtered, *(not null not empty).
return array The array containing all themes that respect the search.
    protected function filterThemes(SearchTheme $search, array $themes)
    {
        //TODO: to implement also the actual filtering.
        $filtered = $themes;
        foreach ($search->getOrderedBy() as $column) {
            if ($column === $search->NAME) {
                $filtered = $this->sort($filtered, 'getName', $column->isOrderAscending());
            } else {
                if ($column === $search->DESIGNER) {
                    $filtered = $this->sort($filtered, 'getDesigner', $column->isOrderAscending());
                } else {
                    if ($column === $search->VERSION) {
                        $filtered = $this->sort($filtered, 'getVersion', $column->isOrderAscending());
                    } else {
                        if ($column === $search->MINOR_NEWSCOOP_VERSION) {
                            $filtered = $this->sort($filtered, 'getMinorNewscoopVersion', $column->isOrderAscending());
                        }
                    }
                }
            }
        }
        return $filtered;
    }