-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[DoctrineBridge][PropertyInfo] Added support for Doctrine Embeddables #23023
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
Changes from 1 commit
b1c1b2f
e1deefd
2420190
d572d53
fff8330
42ffb14
268f545
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,7 +50,19 @@ public function getProperties($class, array $context = array()) | |
return; | ||
} | ||
|
||
return array_merge($metadata->getFieldNames(), $metadata->getAssociationNames()); | ||
$properties = array_merge($metadata->getFieldNames(), $metadata->getAssociationNames()); | ||
|
||
if (class_exists('Doctrine\ORM\Mapping\Embedded')) { | ||
if ($metadata instanceof ClassMetadataInfo && count($metadata->embeddedClasses) > 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
$properties = array_filter($properties, function ($property) { | ||
return false === strpos($property, '.'); | ||
}); | ||
|
||
$properties = array_merge($properties, array_keys($metadata->embeddedClasses)); | ||
} | ||
} | ||
|
||
return $properties; | ||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,21 @@ public function testGetProperties() | |
); | ||
} | ||
|
||
public function testGetEmbeddableProperties() | ||
{ | ||
if (!class_exists('Doctrine\ORM\Mapping\Embedded')) { | ||
return; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should put There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you, fixed this! |
||
} | ||
|
||
$this->assertEquals( | ||
array( | ||
'id', | ||
'embedded', | ||
), | ||
$this->extractor->getProperties('Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineWithEmbedded') | ||
); | ||
} | ||
|
||
/** | ||
* @dataProvider typesProvider | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we'll merge this PR in 3.4, you can import this class and do
class_exists(Embedded::class)
.