bundles/BlockManagerBundle/DependencyInjection/CompilerPass/Block/BlockTypePass.php
private function generateBlockTypeConfig(array $blockTypes, array $blockDefinitions): array
    {
        foreach ($blockDefinitions as $identifier => $blockDefinition) {
            if (
                isset($blockTypes[$identifier]['definition_identifier']) &&
                $blockTypes[$identifier]['definition_identifier'] !== '' &&
                $blockTypes[$identifier]['definition_identifier'] !== null &&
                $blockTypes[$identifier]['definition_identifier'] !== $identifier
            ) {
                // We skip the block types which have been completely redefined
                // i.e. had the block definition identifier changed
                continue;
            }

            if (!isset($blockTypes[$identifier])) {
                $blockTypes[$identifier] = [
                    'name' => $blockDefinition['name'],
                    'icon' => $blockDefinition['icon'],
                    'enabled' => $blockDefinition['enabled'],
                    'definition_identifier' => $identifier,
                    'defaults' => [],
                ];

                continue;
            }

            if (!$blockDefinition['enabled']) {
                $blockTypes[$identifier]['enabled'] = false;
            } elseif (!isset($blockTypes[$identifier]['enabled'])) {
                $blockTypes[$identifier]['enabled'] = true;
            }

            $blockTypes[$identifier] += [
                'name' => $blockDefinition['name'],
                'icon' => $blockDefinition['icon'],
                'definition_identifier' => $identifier,
            ];
        }

        foreach ($blockTypes as $identifier => $blockType) {
            $definitionIdentifier = $blockType['definition_identifier'] ?? $identifier;

            if (!isset($blockDefinitions[$definitionIdentifier])) {
                continue;
            }

            if (!$blockDefinitions[$definitionIdentifier]['enabled']) {
                $blockTypes[$identifier]['enabled'] = false;
            }
        }

        return $blockTypes;
    }
private function generateBlockTypeConfig(array $blockTypes, array $blockDefinitions): array
    {
        foreach ($blockDefinitions as $identifier => $blockDefinition) {
            if (
                isset($blockTypes[$identifier]['definition_identifier']) &&
                $blockTypes[$identifier]['definition_identifier'] !== '' &&
                $blockTypes[$identifier]['definition_identifier'] !== null &&
                $blockTypes[$identifier]['definition_identifier'] !== $identifier
            ) {
                // We skip the block types which have been completely redefined
                // i.e. had the block definition identifier changed
                continue;
            }

            if (!isset($blockTypes[$identifier])) {
                $blockTypes[$identifier] = [
                    'name' => $blockDefinition['name'],
                    'icon' => $blockDefinition['icon'],
                    'enabled' => $blockDefinition['enabled'],
                    'definition_identifier' => $identifier,
                    'defaults' => [],
                ];

                continue;
            }

            if (!$blockDefinition['enabled']) {
                $blockTypes[$identifier]['enabled'] = false;
            } elseif (!isset($blockTypes[$identifier]['enabled'])) {
                $blockTypes[$identifier]['enabled'] = true;
            }

            $blockTypes[$identifier] += [
                'name' => $blockDefinition['name'],
                'icon' => $blockDefinition['icon'],
                'definition_identifier' => $identifier,
            ];
        }

        foreach ($blockTypes as $identifier => $blockType) {
            $definitionIdentifier = $blockType['definition_identifier'] ?? $identifier;

            if (!isset($blockDefinitions[$definitionIdentifier])) {
                continue;
            }

            if (!$blockDefinitions[$definitionIdentifier]['enabled']) {
                $blockTypes[$identifier]['enabled'] = false;
            }
        }

        return $blockTypes;
    }
private function generateBlockTypeConfig ( array $ blockTypes , array $ blockDefinitions ) : array { foreach ( $ blockDefinitions as $ identifier => $ blockDefinition ) { if ( isset ( $ blockTypes [ $ identifier ] [ 'definition_identifier' ] ) && $ blockTypes [ $ identifier ] [ 'definition_identifier' ] !== '' && $ blockTypes [ $ identifier ] [ 'definition_identifier' ] !== null && $ blockTypes [ $ identifier ] [ 'definition_identifier' ] !== $ identifier ) { // We skip the block types which have been completely redefined // i.e. had the block definition identifier changed continue ; } if ( ! isset ( $ blockTypes [ $ identifier ] ) ) { $ blockTypes [ $ identifier ] = [ 'name' => $ blockDefinition [ 'name' ] , 'icon' => $ blockDefinition [ 'icon' ] , 'enabled' => $ blockDefinition [ 'enabled' ] , 'definition_identifier' => $ identifier , 'defaults' => [ ] , ] ; continue ; } if ( ! $ blockDefinition [ 'enabled' ] ) { $ blockTypes [ $ identifier ] [ 'enabled' ] = false ; } elseif ( ! isset ( $ blockTypes [ $ identifier ] [ 'enabled' ] ) ) { $ blockTypes [ $ identifier ] [ 'enabled' ] = true ; } $ blockTypes [ $ identifier ] += [ 'name' => $ blockDefinition [ 'name' ] , 'icon' => $ blockDefinition [ 'icon' ] , 'definition_identifier' => $ identifier , ] ; } foreach ( $ blockTypes as $ identifier => $ blockType ) { $ definitionIdentifier = $ blockType [ 'definition_identifier' ] ?? $ identifier ; if ( ! isset ( $ blockDefinitions [ $ definitionIdentifier ] ) ) { continue ; } if ( ! $ blockDefinitions [ $ definitionIdentifier ] [ 'enabled' ] ) { $ blockTypes [ $ identifier ] [ 'enabled' ] = false ; } } return $ blockTypes ; }
Generates the block type configuration from provided block definitions.
Generates the block type configuration from provided block definitions .