private function renderCollection(EnvironmentInterface $environment, CollectionInterface $collection, $grouping)
    {
        $listing    = $this->getViewSection($environment->getDataDefinition())->getListingConfig();
        $remoteCur  = null;
        $groupClass = 'tl_folder_tlist';
        $eoCount    = -1;

        // Generate buttons - only if not in select mode!
        if ('select' !== $environment->getInputProvider()->getParameter('act')) {
            $buttonRenderer = new ButtonRenderer($environment);
            $buttonRenderer->renderButtonsForCollection($collection);
        }

        // Run each model.
        foreach ($collection as $model) {
            /** @var ModelInterface $model */
            $this->addGroupHeader($environment, (array) $grouping, $model, $groupClass, $eoCount, $remoteCur);

            if ($listing->getItemCssClass()) {
                $model->setMeta($model::CSS_CLASS, $listing->getItemCssClass());
            }
            $cssClasses = [(0 === (++$eoCount) % 2) ? 'even' : 'odd'];

            (null !== $model->getMeta($model::CSS_ROW_CLASS)) ?
                $cssClasses[] = $model->getMeta($model::CSS_ROW_CLASS) : null;

            $modelId = ModelId::fromModel($model);
            if ($environment->getClipboard()->hasId($modelId)) {
                $cssClasses[] = 'tl_folder_clipped';
            }

            $model->setMeta($model::CSS_ROW_CLASS, \implode(' ', $cssClasses));

            $this->renderModel($model, $environment);
        }
    }