forked from symfony/ux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Turbo] Fixing support for not using old ClassUtils
- Loading branch information
1 parent
40d9f11
commit 4753fc3
Showing
4 changed files
with
45 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\UX\Turbo\Doctrine; | ||
|
||
use Symfony\Component\VarExporter\LazyObjectInterface; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class ClassUtil | ||
{ | ||
public static function getEntityClass(object $entity): string | ||
{ | ||
if ($entity instanceof LazyObjectInterface) { | ||
$entityClass = get_parent_class($entity); | ||
if (false === $entityClass) { | ||
throw new \LogicException('Parent class missing'); | ||
} | ||
|
||
return $entityClass; | ||
} | ||
|
||
// @legacy for old versions of Doctrine | ||
if (class_exists(ClassUtils::class)) { | ||
return ClassUtils::getClass($entity); | ||
} | ||
|
||
return $entity::class; | ||
} | ||
} |