protected function getCollectionFromSession(Action $action, EnvironmentInterface $environment)
    {
        $inputProvider  = $environment->getInputProvider();
        $sessionStorage = $environment->getSessionStorage();
        $dataDefinition = $environment->getDataDefinition();
        $dataProvider   = $environment->getDataProvider($dataDefinition->getName());

        $addEditProperties =
            $inputProvider->hasValue('FORM_INPUTS')
            && ($dataDefinition->getName() === $inputProvider->getValue('FORM_SUBMIT'));

        $session = $this->getSession($action, $environment);

        $editProperties = [];

        $modelIds = [];
        foreach ($session['models'] as $modelId) {
            $modelIds[] = ModelId::fromSerialized($modelId)->getId();

            if ($addEditProperties) {
                $modelEditProperties = $inputProvider->getValue(\str_replace('::', '____', $modelId) . '_', true);
                $inputProvider->unsetValue(\str_replace('::', '____', $modelId) . '_');

                $editProperties[$modelId] = $modelEditProperties;
            }
        }

        $idProperty = \method_exists($dataProvider, 'getIdProperty') ? $dataProvider->getIdProperty() : 'id';
        $collection = $dataProvider->fetchAll(
            $dataProvider->getEmptyConfig()->setFilter(
                [['operation' => 'IN', 'property' => $idProperty, 'values' => $modelIds]]
            )
        );

        $session['editProperties'] = $editProperties;

        $sessionStorage->set($dataDefinition->getName() . '.' . $this->getMode($action), $session);

        return $collection;
    }