Upgrading from 1.4.0 to 2.0.0
Upgrade composer.json
In your composer.json file, upgrade the version of netgen/layouts-core
package and all other related packages (like netgen/layouts-standard,
netgen/layouts-ibexa and others) to ~2.0.0 and run the
composer update command.
Upgrading Netgen Content Browser
Netgen Content Browser version 2.0 was also automatically installed. Be sure to read its upgrade instructions too.
Breaking changes
Minimum supported version of PHP is now 8.4
Minimum supported version of Symfony is now 7.3
Layouts exported with older version of Netgen Layouts cannot be imported into version 2.0
Ramsey UUID has been replaced by Symfony Uid component. Replace your typehints to use
Symfony\Component\Uid\Uuidinstead ofRamsey\Uuid\UuidInterfaceandRamsey\Uuid\Uuid.Missing parameter and return types have been added. This is mostly contained to missing union types and the
mixedtype. Mostly, the types have been taken from existing PHPDoc annotations, but in certain cases, where it was physically impossible to pass or return some types, those were made more strict. This should not have impact on your existing code (apart from adding the required types as needed).Property hooks and asymmetric visibility have been introduced across the board. This means that wherever possible (meaning, in value objects), getters have been removed and replaced with properties.
This will have most impact on your query type handlers, where you directly access the
Queryobject to execute queries:Before:
$value = $query->getParameter('param')->getValue(); $isEmpty = $query->getParameter('param')->isEmpty();
After:
$value = $query->getParameter('param')->value; $isEmpty = $query->getParameter('param')->isEmpty;
This change is (mostly) backwards compatible with your existing Twig templates.
Note that in cases of boolean getters (e.g.
isEmpty()method replaced withisEmptyproperty inNetgen\Layouts\Parameters\Parameterclass), you will need to update your Twig templates to use the new name, since Twig does not have fallback foris*methods like it has for getter methods:Before:
{% if block.parameter('foo').empty %}
After:
{% if block.parameter('foo').isEmpty %}
In API value objects,
$statusproperty is now an enum of typeNetgen\Layouts\API\Values\Statusinstead of an integer. This change is also reflected in API services and other classes wherever status is provided as one of the arguments/properties/return values.nglayouts_item_pathTwig function cannot be used any more to generate admin URLs to your items. A new function,nglayouts_item_admin_pathhas been implemented for that purpose:Before:
{{ nglayouts_item_path(item, 'admin') }}
After:
{{ nglayouts_item_admin_path(item) }}
Netgen\Layouts\API\Values\Layout\LayoutandNetgen\Layouts\API\Values\Block\Placeholderdo not implementArrayAccess,CountableandIteratorAggregateany more. UseLayout::$zonesorPlaceholder::$blocksproperties directly instead.@NetgenLayoutsAdmin/app/block/block.html.twigtemplate has been removed. Use@nglayouts_admin/app/block/block.html.twiginstead.BlockService::loadPlaceholderBlocksmethod has been added to the interface.LayoutResolverService::loadRulesmethod has been removed. UseLayoutResolverService::loadRulesFromGrouporLayoutResolverService::loadRulesForLayoutinstead.LayoutResolverService::getRuleCountmethod has been removed. UseLayoutResolverService::getRuleCountFromGrouporLayoutResolverService::getRuleCountForLayoutinstead.LayoutResolverService::loadConditionmethod has been removed. UseLayoutResolverService::loadRuleConditioninstead.LayoutResolverService::loadConditionDraftmethod has been removed. UseLayoutResolverService::loadRuleConditionDraftinstead.LayoutResolverService::createDraftmethod has been removed. UseLayoutResolverService::createRuleDraftinstead.LayoutResolverService::discardDraftmethod has been removed. UseLayoutResolverService::discardRuleDraftinstead.LayoutResolverService::restoreFromArchivemethod has been removed. UseLayoutResolverService::restoreRuleFromArchiveinstead.LayoutResolverService::addConditionmethod has been removed. UseLayoutResolverService::addRuleConditioninstead.LayoutResolverService::updateConditionmethod has been removed. UseLayoutResolverService::updateRuleConditioninstead.LayoutService::hasStatusmethod has been removed. UseLayoutResolverService::layoutExistsinstead.BlockCreateStruct::$nameproperty does not accept nulls any more.LayoutCreateStruct::$descriptionproperty does not accept nulls any more.Rule::getCommentmethod has been removed in favor or$descriptionproperty.RuleCreateStruct::$commenthas been removed in favor of$descriptionproperty.RuleUpdateStruct::$commenthas been removed in favor of$descriptionproperty.Netgen\Layouts\Block\BlockDefinition\Handler\PluginInterface::getExtendedIdentifiershas been added to the interface. If you extended the abstractNetgen\Layouts\Block\BlockDefinition\Handler\Pluginclass in your plugins, you don’t have to do anything here as the empty method implementation is already available there. Otherwise, implement the method in your plugins.Netgen\Layouts\Item\ExtendedValueUrlGeneratorInterfaceinterface has been removed and merged into the mainNetgen\Layouts\Item\ValueUrlGeneratorInterfaceinterface.Netgen\Layouts\Item\ValueUrlGeneratorInterface::generatemethod has been removed. ImplementgenerateDefaultUrlandgenerateAdminUrlinstead.Netgen\Layouts\Layout\Resolver\ConditionTypeInterface::exportandNetgen\Layouts\Layout\Resolver\ConditionTypeInterface::importhave been added to the interface. If you extended the abstractNetgen\Layouts\Layout\Resolver\ConditionTypeclass in your condition types, you don’t have to do anything here as the empty method implementations are already available there. Otherwise, implement the methods in your condition types.Netgen\Layouts\Layout\Resolver\TargetTypeInterface::exportandNetgen\Layouts\Layout\Resolver\TargetTypeInterface::importhave been added to the interface. If you extended the abstractNetgen\Layouts\Layout\Resolver\TargetTypeclass in your target types, you don’t have to do anything here as the empty method implementations are already available there. Otherwise, implement the methods in your target types.$requestargument ofLayoutResolverInterface::resolveRulemethod does not accept nulls any more. Current request should be provided instead of passing null.LayoutResolverInterface::matchesmethod has been removed without replacement.nglayouts.admin.matchevent name has been removed in favor of using theNetgen\Bundle\LayoutsAdminBundle\Event\AdminMatchEventclass as the event name.Netgen\Layouts\Event\CollectViewParametersEventevent class has been split intoNetgen\Layouts\Event\BuildViewEventandNetgen\Layouts\Event\RenderViewEvent. It also removed the possibility to add view parameters directly to the event. Access the view inside the event and add the parameters to the view itself.nglayouts.view.build_viewevent name has been removed in favor of usingNetgen\Layouts\Event\BuildViewEventclass as the event name.nglayouts.view.render_viewevent name has been removed in favor of usingNetgen\Layouts\Event\RenderViewEventclass as the event name.typeattribute innetgen_layouts.parameter_type.form_mapperDI tag has been renamed toparameter_typefor consistency with other form mapper DI tagsSylius Product and Sylius Taxon parameter type values have been converted to integers as opposed to numeric strings as were before. Update your query type handlers and templates to work with the new type if needed.
Deprecations
There are no deprecations in Netgen Layouts 2.0.