Install
Works with Drupal: ^10.3 || ^11 || ^12Using Composer to manage Drupal site dependencies
Alternative installation files
Download tar.gz
29.18 KB
MD5: 8d89266e6d50dc5fcde9f8aebefea6df
SHA-1: 9f77c80ae04f28b957985b9645aa4862cc43a561
SHA-256: ceb0ff326a1726ddc2b442a94ce55e0233aef69e288f8cdddae3f17a6d3db981
Download zip
53.78 KB
MD5: de0111fb159fb3352af4342cbdeb3656
SHA-1: e3c12ec76ff6c96573e00ee4c4fd1a06919c0a7a
SHA-256: 7675e1092b0a84dce2fe3e294883defd386ebdc184338caa671014f7b4dea3de
Release notes
Child Entity 2.1.0 modernizes the module for Drupal 10.3+, Drupal 11, and Drupal 12 with PHP 8.4+ strict typing, OOP hooks, dedicated HTML and revision route providers, multi-level hierarchy fixes, and a comprehensive kernel and functional test suite.
Highlights & New Features
- Drupal 11 & 12 / PHP 8.4 Modernization:
- Updated core compatibility to
^10.3 || ^11 || ^12and minimum PHP requirement to>=8.4. - Enforced
declare(strict_types=1);and native parameter, property, and return type hints across the entire module. - Migrated procedural hooks (
hook_entity_presave(),hook_entity_type_alter()) to an OOP hook class (Drupal\child_entity\Hook\ChildEntityHooks) using#[Hook]attributes, with#[LegacyHook]procedural shims inchild_entity.modulefor backward compatibility.
- Updated core compatibility to
- Dedicated Route Providers & Revision Support:
- Added
ChildDefaultHtmlRouteProvider,ChildAdminHtmlRouteProvider, andChildRevisionHtmlRouteProvider(for revision history, view, revert, and delete routes prefixed with parent parameters). - Extracted shared route preparation and parent parameter upcasting logic into
ChildEntityRouteProviderTrait. - Added
ChildEntityHelperfor static entity type validation (validateChildEntityType(),isChildEntityType()) without triggering PHP 8.4/8.5 static trait call deprecations.
- Added
- Data Integrity & Form Enforcement:
hook_entity_presave()now attempts to recover a missing parent reference from the active route match before throwing a\LogicExceptionif a child entity is saved without a parent.hook_entity_type_alter()validates that non-confirm content entity forms (default,add,edit) on child entities extendChildContentEntityForm.- Marked the parent
entity_referencebase field inChildEntityTrait::childBaseFieldDefinitions()asrequiredandrevisionable(when the child entity type is revisionable).
- Automated Test Suite:
- Added the
child_entity_testtest module and automated PHPUnit Kernel and Functional tests covering 2-level and 3-level entity hierarchies, routing, route contexts, access delegation, dynamic permissions, presave integrity, and UI workflows.
- Added the
Bug Fixes
- Fixed multi-level parent parameter recursion: Fixed infinite recursion in
ChildEntityTrait::buildParentParams()and updatedChildEntityController::addPage()to walk the full ancestor chain when building bundle add links and single-bundle redirects. - Fixed route context resolution: Fixed
ChildEntityRouteContext::getRuntimeContexts()key mismatches between child and parent entity type IDs and registeredChildEntityRouteSubscriberinchild_entity.services.yml. - Fixed bundle & revision permission generation: Fixed bundle key iteration in
ChildEntityPermissions::generatePermissions()and restricted revision permissions to revisionable child entity types. - Fixed bundle-less
add-formroute errors: GuardedChildEntityController::addPage()when a bundle config entity type does not define anadd-formlink template.
API Changes & Deprecations
ChildEntityInterfacenow explicitly extendsDrupal\Core\Entity\ContentEntityInterface, allows nullable returns ongetParentEntity(): ?EntityInterfaceandgetParentId(): int|string|null, and uses: staticreturn types onsetParentId()andsetParentEntity().ChildContentEntityHtmlRouteProvideris deprecated inchild_entity:2.1.0and will be removed inchild_entity:3.0.0. UseDrupal\child_entity\Routing\ChildAdminHtmlRouteProviderorDrupal\child_entity\Routing\ChildDefaultHtmlRouteProviderinstead.