src/Contao/View/Contao2BackendView/ActionHandler/SelectHandler.php
private function collectIntersectValues(CollectionInterface $collection, EnvironmentInterface $environment)
    {
        $sessionStorage = $environment->getSessionStorage();
        $dataDefinition = $environment->getDataDefinition();

        $session = $sessionStorage->get($dataDefinition->getName() . '.' . $this->getSubmitAction($environment, true));

        $values = [];
        foreach ($collection->getIterator() as $model) {
            $modelValues = \array_intersect_key($model->getPropertiesAsArray(), $session['intersectProperties']);
            foreach ($modelValues as $modelProperty => $modelValue) {
                if (1 === $collection->count()) {
                    $values[$modelProperty] = $modelValue;

                    continue;
                }

                $values[$modelProperty][] = $modelValue;
            }
        }

        if (1 === $collection->count()) {
            return $values;
        }

        $intersectValues = [];
        foreach ($values as $propertyName => $propertyValues) {
            if (!($value = $this->getUniqueValueFromArray($propertyValues))) {
                continue;
            }

            $intersectValues[$propertyName] = $value;
        }

        return $intersectValues;
    }
private function collectIntersectValues(CollectionInterface $collection, EnvironmentInterface $environment)
    {
        $sessionStorage = $environment->getSessionStorage();
        $dataDefinition = $environment->getDataDefinition();

        $session = $sessionStorage->get($dataDefinition->getName() . '.' . $this->getSubmitAction($environment, true));

        $values = [];
        foreach ($collection->getIterator() as $model) {
            $modelValues = \array_intersect_key($model->getPropertiesAsArray(), $session['intersectProperties']);
            foreach ($modelValues as $modelProperty => $modelValue) {
                if (1 === $collection->count()) {
                    $values[$modelProperty] = $modelValue;

                    continue;
                }

                $values[$modelProperty][] = $modelValue;
            }
        }

        if (1 === $collection->count()) {
            return $values;
        }

        $intersectValues = [];
        foreach ($values as $propertyName => $propertyValues) {
            if (!($value = $this->getUniqueValueFromArray($propertyValues))) {
                continue;
            }

            $intersectValues[$propertyName] = $value;
        }

        return $intersectValues;
    }
private function collectIntersectValues ( CollectionInterface $ collection , EnvironmentInterface $ environment ) { $ sessionStorage = $ environment -> getSessionStorage ( ) ; $ dataDefinition = $ environment -> getDataDefinition ( ) ; $ session = $ sessionStorage -> get ( $ dataDefinition -> getName ( ) . '.' . $ this -> getSubmitAction ( $ environment , true ) ) ; $ values = [ ] ; foreach ( $ collection -> getIterator ( ) as $ model ) { $ modelValues = \ array_intersect_key ( $ model -> getPropertiesAsArray ( ) , $ session [ 'intersectProperties' ] ) ; foreach ( $ modelValues as $ modelProperty => $ modelValue ) { if ( 1 === $ collection -> count ( ) ) { $ values [ $ modelProperty ] = $ modelValue ; continue ; } $ values [ $ modelProperty ] [ ] = $ modelValue ; } } if ( 1 === $ collection -> count ( ) ) { return $ values ; } $ intersectValues = [ ] ; foreach ( $ values as $ propertyName => $ propertyValues ) { if ( ! ( $ value = $ this -> getUniqueValueFromArray ( $ propertyValues ) ) ) { continue ; } $ intersectValues [ $ propertyName ] = $ value ; } return $ intersectValues ; }
Collect the intersect values from the model collection.

@param CollectionInterface  $collection  The collection.
@param EnvironmentInterface $environment The environment.

@return array
Collect the intersect values from the model collection .