Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Turbo] Fixing support for not using old ClassUtils #1471

Merged

Conversation

weaverryan
Copy link
Member

Q A
Bug fix? yes
New feature? no
Issues Fix #1469
License MIT

@carsonbot carsonbot added the Status: Needs Review Needs to be reviewed label Feb 7, 2024
@weaverryan weaverryan force-pushed the turbo-doctrine-class-utils-support branch from 79cb86c to 536f8b1 Compare February 7, 2024 20:19
@weaverryan weaverryan force-pushed the turbo-doctrine-class-utils-support branch from 536f8b1 to 4753fc3 Compare February 7, 2024 20:23
@weaverryan weaverryan merged commit adb2cbb into symfony:2.x Feb 7, 2024
@weaverryan
Copy link
Member Author

This, indeed, fixes the reported problem

@weaverryan weaverryan deleted the turbo-doctrine-class-utils-support branch February 7, 2024 20:23
}

// @legacy for old versions of Doctrine
if (class_exists(ClassUtils::class)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class is not imported so it will always return false.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

if ($entity instanceof LazyObjectInterface) {
$entityClass = get_parent_class($entity);
if (false === $entityClass) {
throw new \LogicException('Parent class missing');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for this exception IMHO, using get_class should be the way if there's no parent

public static function getEntityClass(object $entity): string
{
if ($entity instanceof LazyObjectInterface) {
$entityClass = get_parent_class($entity);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return get_parent_class($entity) ?: \get_class($entity);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Review Needs to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade to Doctrine ORM 3.0 breaks Turbo
5 participants