protected function getActiveCategories(array $customCategories = [])
    {
        $param = System::getContainer()->get('codefog_news_categories.manager')->getParameterName();

        if (!($aliases = Input::get($param))) {
            return null;
        }

        $aliases = StringUtil::trimsplit(static::getCategorySeparator(), $aliases);
        $aliases = array_unique(array_filter($aliases));

        if (count($aliases) === 0) {
            return null;
        }

        // Get the categories that do have news assigned
        $models = NewsCategoryModel::findPublishedByArchives($this->news_archives, $customCategories, $aliases);

        // No models have been found but there are some aliases present
        if ($models === null && count($aliases) !== 0) {
            Controller::redirect($this->getTargetPage()->getFrontendUrl());
        }

        // Validate the provided aliases with the categories found
        if ($models !== null) {
            $realAliases = [];

            /** @var NewsCategoryModel $model */
            foreach ($models as $model) {
                $realAliases[] = $this->manager->getCategoryAlias($model, $GLOBALS['objPage']);
            }

            if (count(array_diff($aliases, $realAliases)) > 0) {
                Controller::redirect($this->getTargetPage()->getFrontendUrl(sprintf(
                    '/%s/%s',
                    $this->manager->getParameterName($GLOBALS['objPage']->rootId),
                    implode(static::getCategorySeparator(), $realAliases)
                )));
            }
        }

        return $models;
    }
protected function getActiveCategories(array $customCategories = [])
    {
        $param = System::getContainer()->get('codefog_news_categories.manager')->getParameterName();

        if (!($aliases = Input::get($param))) {
            return null;
        }

        $aliases = StringUtil::trimsplit(static::getCategorySeparator(), $aliases);
        $aliases = array_unique(array_filter($aliases));

        if (count($aliases) === 0) {
            return null;
        }

        // Get the categories that do have news assigned
        $models = NewsCategoryModel::findPublishedByArchives($this->news_archives, $customCategories, $aliases);

        // No models have been found but there are some aliases present
        if ($models === null && count($aliases) !== 0) {
            Controller::redirect($this->getTargetPage()->getFrontendUrl());
        }

        // Validate the provided aliases with the categories found
        if ($models !== null) {
            $realAliases = [];

            /** @var NewsCategoryModel $model */
            foreach ($models as $model) {
                $realAliases[] = $this->manager->getCategoryAlias($model, $GLOBALS['objPage']);
            }

            if (count(array_diff($aliases, $realAliases)) > 0) {
                Controller::redirect($this->getTargetPage()->getFrontendUrl(sprintf(
                    '/%s/%s',
                    $this->manager->getParameterName($GLOBALS['objPage']->rootId),
                    implode(static::getCategorySeparator(), $realAliases)
                )));
            }
        }

        return $models;
    }
protected function getActiveCategories ( array $ customCategories = [ ] ) { $ param = System :: getContainer ( ) -> get ( 'codefog_news_categories.manager' ) -> getParameterName ( ) ; if ( ! ( $ aliases = Input :: get ( $ param ) ) ) { return null ; } $ aliases = StringUtil :: trimsplit ( static :: getCategorySeparator ( ) , $ aliases ) ; $ aliases = array_unique ( array_filter ( $ aliases ) ) ; if ( count ( $ aliases ) === 0 ) { return null ; } // Get the categories that do have news assigned $ models = NewsCategoryModel :: findPublishedByArchives ( $ this -> news_archives , $ customCategories , $ aliases ) ; // No models have been found but there are some aliases present if ( $ models === null && count ( $ aliases ) !== 0 ) { Controller :: redirect ( $ this -> getTargetPage ( ) -> getFrontendUrl ( ) ) ; } // Validate the provided aliases with the categories found if ( $ models !== null ) { $ realAliases = [ ] ; /** @var NewsCategoryModel $model */ foreach ( $ models as $ model ) { $ realAliases [ ] = $ this -> manager -> getCategoryAlias ( $ model , $ GLOBALS [ 'objPage' ] ) ; } if ( count ( array_diff ( $ aliases , $ realAliases ) ) > 0 ) { Controller :: redirect ( $ this -> getTargetPage ( ) -> getFrontendUrl ( sprintf ( '/%s/%s' , $ this -> manager -> getParameterName ( $ GLOBALS [ 'objPage' ] -> rootId ) , implode ( static :: getCategorySeparator ( ) , $ realAliases ) ) ) ) ; } } return $ models ; }
Get the active categories

@param array $customCategories

@return Collection|null
Get the active categories