Description
Environment
Development Env
Package
show
$ composer show --latest gedmo/doctrine-extensions
# Put the result here.
name : gedmo/doctrine-extensions descrip. : Doctrine behavioral extensions keywords : Blameable, behaviors, doctrine, extensions, gedmo, loggable, nestedset, odm, orm, sluggable, sortable, timestampable, translatable, tree, uploadable versions : * v3.18.0 released : 2025-02-01, last week latest : v3.18.0 released 2025-02-01, last week type : library license : MIT License (MIT) (OSI approved) https://spdx.org/licenses/MIT.html#licenseText homepage : http://gediminasm.org/ source : [git] https://github.com/doctrine-extensions/DoctrineExtensions.git 964db6c dist : [zip] https://api.github.com/repos/doctrine-extensions/DoctrineExtensions/zipball/964db6c4fb5b0fc8aa25cc31b17471b4963460c6 964db6c path : D:\projects\Venera\venera-carpet.ru\src\Venera\vendor\gedmo\doctrine-extensions names : gedmo/doctrine-extensions
Doctrine packages
show
$ composer show --latest 'doctrine/*'
# Put the result here.
"doctrine/doctrine-bundle": "^2.13",
"doctrine/doctrine-migrations-bundle": "^3.4",
"doctrine/orm": "^3.3",
PHP version
$ php -v
# Put the result here.
PHP 8.4.2 (cli) (built: Dec 17 2024 17:30:12) (ZTS Visual C++ 2022 x64) Copyright (c) The PHP Group Zend Engine v4.4.2, Copyright (c) Zend Technologies with Zend OPcache v8.4.2, Copyright (c), by Zend Technologies with Xdebug v3.4.1, Copyright (c) 2002-2025, by Derick Rethans
Subject
Minimal repository with the bug
Steps to reproduce
- Create Category with nested tree example
from documentation https://github.com/doctrine-extensions/DoctrineExtensions/blob/main/doc/tree.md#building-trees-from-your-entities - And try to get tree by Entites (not array)
- I got the error
An exception has been thrown during the rendering of a template ("Unknown property "mappedBy" on class Doctrine\ORM\Mapping\ManyToOneAssociationMapping"). - Then debug on
src/Venera/vendor/gedmo/doctrine-extensions/src/Tree/Hydrator/ORM/TreeObjectHydrator.php
on Line 249
// Make sure the association is mapped by the parent property
if ($associationMapping['mappedBy'] !== $this->parentField) {
continue;
}
$associationMapping['mappedBy'] call the exception because Category->parent does not have mappedBy
I fixed it by changing Category entity. Firstly I put $children and after put $parent property.
Activity