kaliop-uk / ezmigrationbundle

This bundle makes it easy to handle eZPlatform / eZPublish5 content upgrades/migrations
GNU General Public License v2.0
53 stars 81 forks source link

Unable to set 'defaultLayout' for ezpage content types - ez flow #175

Closed SalvatorePollaci closed 6 years ago

SalvatorePollaci commented 6 years ago

Hi, I am using ez platform 2.3 with Legacy Bridge and via ez flow configuration I have enabled some layouts for my content type(e.g. SingleZoneLayout). Via backoffice panel, I can successfully set the default layout to 'SingleZoneLayout', but it seems impossibile via ezmigrationbundle.

ez migration file

type: content_type
mode: update
...
attributes:
    ...
    -
            identifier: layout
            type: ezpage
            name:
                eng-GB: Layout
            description:
                eng-GB: ''
            required: false
            searchable: false
            info-collector: false
            disable-translation: false
            category: ''
            position: 5
            field-settings:
                defaultLayout: SingleZoneLayout
            validator-configuration: {  }

Error Message

Migration aborted! Reason: Error in execution of step 2: ContentType FieldDefinitions did not validate
Layout 'SingleZoneLayout' for setting '%setting%' is not available - array (
  '%setting%' => 'defaultLayout',
) in file /var/www/html/project/ezplatform/vendor/ezsystems/ezpublish-kernel/eZ/Publish/Core/Repository/Helper/ContentTypeDomainMapper.php line 319

Notes It seems that the error message is generated here:

/vendor/ezsystems/ezpublish-kernel/eZ/Publish/Core/FieldType/Page/Type.php

/**
     * Validates the fieldSettings of a FieldDefinitionCreateStruct or FieldDefinitionUpdateStruct.
     *
     * @param mixed $fieldSettings
     *
     * @return \eZ\Publish\SPI\FieldType\ValidationError[]
     */
    public function validateFieldSettings($fieldSettings)
    {
        $validationErrors = array();

        foreach ($fieldSettings as $name => $value) {
            if (isset($this->settingsSchema[$name])) {
                switch ($name) {
                    case 'defaultLayout':
                        if ($value !== '' && !in_array($value, $this->pageService->getAvailableZoneLayouts())) {
                            $validationErrors[] = new ValidationError(
                                "Layout '{$value}' for setting '%setting%' is not available",
                                null,
                                array(
                                    '%setting%' => $name,
                                ),
                                "[$name]"
                            );
                        }
                        break;
                }
            } else {
                $validationErrors[] = new ValidationError(
                    "Setting '%setting%' is unknown",
                    null,
                    array(
                        '%setting%' => $name,
                    ),
                    "[$name]"
                );
            }
        }

        return $validationErrors;
    }

Hypothesis I think that ez migration is trying to access the ezplatform page builder service to obtain possibile layouts and is not referring to ezflow configurations. Therefore it seems incompatible with ezflow/legacy bridge.

einfoadm commented 6 years ago

Yes, I am also encountering this issue! Has anyone found any solutions?

gggeek commented 6 years ago

Well, at least as far as eZPublish 5.4 / 2018.xx is concerned, you have to define ezflow layouts twice, both in legacy ini (for the backoffice) and in yml files. Is the situation different for ezplatform + legacy-bridge?

SalvatorePollaci commented 6 years ago

@gggeek Thank you. I didn't know about that. I have now created a config file like the following:

https://github.com/ezsystems/DemoBundle/blob/master/Resources/config/ezpage.yml#L109

and it is working great.

This issue can now be closed.

Thanks