lib/Block/Form/EditType.php
private function processViewTypeConfig(BlockDefinitionInterface $blockDefinition): void
    {
        $blockDefinitionParameters = array_keys($blockDefinition->getParameterDefinitions());

        foreach ($blockDefinition->getViewTypes() as $viewType) {
            $this->viewTypes[$viewType->getIdentifier()] = $viewType->getName();

            foreach ($viewType->getItemViewTypes() as $itemViewType) {
                $this->itemViewTypes[$viewType->getIdentifier()][$itemViewType->getIdentifier()] = $itemViewType->getName();
                $this->viewTypesByItemViewType[$itemViewType->getIdentifier()][] = $viewType->getIdentifier();
            }

            $includedParameters = [];
            $excludedParameters = [];

            $validParameters = $viewType->getValidParameters();
            if (!is_array($validParameters)) {
                $includedParameters = $blockDefinitionParameters;
            } elseif (count($validParameters) > 0) {
                foreach ($validParameters as $validParameter) {
                    mb_strpos($validParameter, '!') === 0 ?
                        $excludedParameters[] = mb_substr($validParameter, 1) :
                        $includedParameters[] = $validParameter;

                    if (count($includedParameters) === 0) {
                        $includedParameters = $blockDefinitionParameters;
                    }
                }
            }

            foreach ($includedParameters as $includedParameter) {
                if (!in_array($includedParameter, $excludedParameters, true)) {
                    $this->viewTypesByParameters[$includedParameter][] = $viewType->getIdentifier();
                }
            }
        }
    }
private function processViewTypeConfig(BlockDefinitionInterface $blockDefinition): void
    {
        $blockDefinitionParameters = array_keys($blockDefinition->getParameterDefinitions());

        foreach ($blockDefinition->getViewTypes() as $viewType) {
            $this->viewTypes[$viewType->getIdentifier()] = $viewType->getName();

            foreach ($viewType->getItemViewTypes() as $itemViewType) {
                $this->itemViewTypes[$viewType->getIdentifier()][$itemViewType->getIdentifier()] = $itemViewType->getName();
                $this->viewTypesByItemViewType[$itemViewType->getIdentifier()][] = $viewType->getIdentifier();
            }

            $includedParameters = [];
            $excludedParameters = [];

            $validParameters = $viewType->getValidParameters();
            if (!is_array($validParameters)) {
                $includedParameters = $blockDefinitionParameters;
            } elseif (count($validParameters) > 0) {
                foreach ($validParameters as $validParameter) {
                    mb_strpos($validParameter, '!') === 0 ?
                        $excludedParameters[] = mb_substr($validParameter, 1) :
                        $includedParameters[] = $validParameter;

                    if (count($includedParameters) === 0) {
                        $includedParameters = $blockDefinitionParameters;
                    }
                }
            }

            foreach ($includedParameters as $includedParameter) {
                if (!in_array($includedParameter, $excludedParameters, true)) {
                    $this->viewTypesByParameters[$includedParameter][] = $viewType->getIdentifier();
                }
            }
        }
    }
private function processViewTypeConfig ( BlockDefinitionInterface $ blockDefinition ) : void { $ blockDefinitionParameters = array_keys ( $ blockDefinition -> getParameterDefinitions ( ) ) ; foreach ( $ blockDefinition -> getViewTypes ( ) as $ viewType ) { $ this -> viewTypes [ $ viewType -> getIdentifier ( ) ] = $ viewType -> getName ( ) ; foreach ( $ viewType -> getItemViewTypes ( ) as $ itemViewType ) { $ this -> itemViewTypes [ $ viewType -> getIdentifier ( ) ] [ $ itemViewType -> getIdentifier ( ) ] = $ itemViewType -> getName ( ) ; $ this -> viewTypesByItemViewType [ $ itemViewType -> getIdentifier ( ) ] [ ] = $ viewType -> getIdentifier ( ) ; } $ includedParameters = [ ] ; $ excludedParameters = [ ] ; $ validParameters = $ viewType -> getValidParameters ( ) ; if ( ! is_array ( $ validParameters ) ) { $ includedParameters = $ blockDefinitionParameters ; } elseif ( count ( $ validParameters ) > 0 ) { foreach ( $ validParameters as $ validParameter ) { mb_strpos ( $ validParameter , '!' ) === 0 ? $ excludedParameters [ ] = mb_substr ( $ validParameter , 1 ) : $ includedParameters [ ] = $ validParameter ; if ( count ( $ includedParameters ) === 0 ) { $ includedParameters = $ blockDefinitionParameters ; } } } foreach ( $ includedParameters as $ includedParameter ) { if ( ! in_array ( $ includedParameter , $ excludedParameters , true ) ) { $ this -> viewTypesByParameters [ $ includedParameter ] [ ] = $ viewType -> getIdentifier ( ) ; } } } }
Generates the list of valid view types for every item view type
and for every parameter, according to config provided by the block definition.

These lists are used by the interface to hide and show item view types
and parameters based on selected view type.

@todo Move this code somewhere else
Generates the list of valid view types for every item view type and for every parameter according to config provided by the block definition .