Skip to content

Commit

Permalink
Fix invalid method call
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 committed Sep 7, 2020
1 parent 86a8777 commit 115510d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Admin/AbstractAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2413,7 +2413,10 @@ public function isCurrentChild(): bool
public function getCurrentChildAdmin()
{
foreach ($this->children as $children) {
if ($children->isCurrentChild()) {
// NEXT_MAJOR: Remove method_exists check and delete elseif case
if (method_exists($children, 'isCurrentChild') && $children->isCurrentChild()) {
return $children;
} elseif ($children->getCurrentChild()) {
return $children;
}
}
Expand Down
5 changes: 5 additions & 0 deletions tests/Admin/AdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2669,6 +2669,11 @@ public function testGetChildDepth(): void
$this->assertSame(2, $commentVoteAdmin->getChildDepth());
}

/**
* @group legacy
*
* @expectedDeprecation The Sonata\AdminBundle\Admin\AbstractAdmin::getCurrentChild() method is deprecated since version 3.65 and will be removed in 4.0. Use Sonata\AdminBundle\Admin\AbstractAdmin::isCurrentChild() instead.
*/
public function testGetCurrentLeafChildAdmin(): void
{
$postAdmin = new PostAdmin(
Expand Down

0 comments on commit 115510d

Please sign in to comment.