src/Contao/View/Contao2BackendView/ViewHelpers.php
public static function initializeSorting($panel, $dataConfig, $listingConfig)
    {
        // Store default sorting start initializing the panel with an empty sorting.
        $sorting = $dataConfig->getSorting();
        $dataConfig->setSorting([]);
        $panel->initialize($dataConfig);

        // Restore default sorting if panel did not set any.
        if ($sorting && !$dataConfig->getSorting()) {
            $dataConfig->setSorting($sorting);
        }

        // Initialize sorting if not present yet.
        if (!$dataConfig->getSorting() && $listingConfig->getGroupAndSortingDefinition()->hasDefault()) {
            $newSorting = [];
            foreach ($listingConfig->getGroupAndSortingDefinition()->getDefault() as $information) {
                /** @var GroupAndSortingInformationInterface $information */
                $newSorting[$information->getProperty()] = \strtoupper($information->getSortingMode());
            }
            $dataConfig->setSorting($newSorting);
        }
    }
public static function initializeSorting($panel, $dataConfig, $listingConfig)
    {
        // Store default sorting start initializing the panel with an empty sorting.
        $sorting = $dataConfig->getSorting();
        $dataConfig->setSorting([]);
        $panel->initialize($dataConfig);

        // Restore default sorting if panel did not set any.
        if ($sorting && !$dataConfig->getSorting()) {
            $dataConfig->setSorting($sorting);
        }

        // Initialize sorting if not present yet.
        if (!$dataConfig->getSorting() && $listingConfig->getGroupAndSortingDefinition()->hasDefault()) {
            $newSorting = [];
            foreach ($listingConfig->getGroupAndSortingDefinition()->getDefault() as $information) {
                /** @var GroupAndSortingInformationInterface $information */
                $newSorting[$information->getProperty()] = \strtoupper($information->getSortingMode());
            }
            $dataConfig->setSorting($newSorting);
        }
    }
public static function initializeSorting ( $ panel , $ dataConfig , $ listingConfig ) { // Store default sorting start initializing the panel with an empty sorting. $ sorting = $ dataConfig -> getSorting ( ) ; $ dataConfig -> setSorting ( [ ] ) ; $ panel -> initialize ( $ dataConfig ) ; // Restore default sorting if panel did not set any. if ( $ sorting && ! $ dataConfig -> getSorting ( ) ) { $ dataConfig -> setSorting ( $ sorting ) ; } // Initialize sorting if not present yet. if ( ! $ dataConfig -> getSorting ( ) && $ listingConfig -> getGroupAndSortingDefinition ( ) -> hasDefault ( ) ) { $ newSorting = [ ] ; foreach ( $ listingConfig -> getGroupAndSortingDefinition ( ) -> getDefault ( ) as $ information ) { /** @var GroupAndSortingInformationInterface $information */ $ newSorting [ $ information -> getProperty ( ) ] = \ strtoupper ( $ information -> getSortingMode ( ) ) ; } $ dataConfig -> setSorting ( $ newSorting ) ; } }
Initialize the sorting from the panel. Fallback to default sorting if nothing given.

@param PanelContainerInterface $panel         The current panel.
@param ConfigInterface         $dataConfig    The current config.
@param ListingConfigInterface  $listingConfig The listing config.

@return void
Initialize the sorting from the panel . Fallback to default sorting if nothing given .