src/Contao/View/Contao2BackendView/ViewHelpers.php
public static function getCurrentSorting(EnvironmentInterface $environment)
    {
        /** @var BackendViewInterface $view */
        $view = $environment->getView();

        foreach ($view->getPanel() as $panel) {
            /** @var PanelInterface $panel */
            $sort = $panel->getElement('sort');
            if ($sort) {
                /** @var SortElementInterface $sort */
                return $sort->getSelectedDefinition();
            }
        }

        /** @var Contao2BackendViewDefinitionInterface $viewSection */
        $viewSection = $environment->getDataDefinition()->getDefinition(Contao2BackendViewDefinitionInterface::NAME);
        $definition  = $viewSection->getListingConfig()->getGroupAndSortingDefinition();
        if ($definition->hasDefault()) {
            return $definition->getDefault();
        }

        return null;
    }
public static function getCurrentSorting(EnvironmentInterface $environment)
    {
        /** @var BackendViewInterface $view */
        $view = $environment->getView();

        foreach ($view->getPanel() as $panel) {
            /** @var PanelInterface $panel */
            $sort = $panel->getElement('sort');
            if ($sort) {
                /** @var SortElementInterface $sort */
                return $sort->getSelectedDefinition();
            }
        }

        /** @var Contao2BackendViewDefinitionInterface $viewSection */
        $viewSection = $environment->getDataDefinition()->getDefinition(Contao2BackendViewDefinitionInterface::NAME);
        $definition  = $viewSection->getListingConfig()->getGroupAndSortingDefinition();
        if ($definition->hasDefault()) {
            return $definition->getDefault();
        }

        return null;
    }
public static function getCurrentSorting ( EnvironmentInterface $ environment ) { /** @var BackendViewInterface $view */ $ view = $ environment -> getView ( ) ; foreach ( $ view -> getPanel ( ) as $ panel ) { /** @var PanelInterface $panel */ $ sort = $ panel -> getElement ( 'sort' ) ; if ( $ sort ) { /** @var SortElementInterface $sort */ return $ sort -> getSelectedDefinition ( ) ; } } /** @var Contao2BackendViewDefinitionInterface $viewSection */ $ viewSection = $ environment -> getDataDefinition ( ) -> getDefinition ( Contao2BackendViewDefinitionInterface :: NAME ) ; $ definition = $ viewSection -> getListingConfig ( ) -> getGroupAndSortingDefinition ( ) ; if ( $ definition -> hasDefault ( ) ) { return $ definition -> getDefault ( ) ; } return null ; }
Retrieve the currently active sorting.

@param EnvironmentInterface $environment The environment.

@return GroupAndSortingDefinitionInterface
Retrieve the currently active sorting .