Skip to content

Commit

Permalink
Better class names for merged objects by using given IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
wol-soft committed Sep 12, 2019
1 parent 23d47b1 commit 0389cb1
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ protected function generateValidators(PropertyInterface $property, array $proper
// NotProcessor) the value must be proposed before the validation
'postPropose' => $this instanceof ComposedPropertiesInterface,
'mergedProperty' =>
$createMergedProperty ? $this->createMergedProperty($property, $properties) : null,
$createMergedProperty
? $this->createMergedProperty($property, $properties, $propertyData)
: null,
'onlyForDefinedValues' =>
$propertyData['onlyForDefinedValues'] && $this instanceof ComposedPropertiesInterface,
]
Expand All @@ -98,13 +100,21 @@ protected function generateValidators(PropertyInterface $property, array $proper
*
* @param PropertyInterface $compositionProperty
* @param CompositionPropertyDecorator[] $properties
* @param array $propertyData
*
* @return PropertyInterface
*/
private function createMergedProperty(PropertyInterface $compositionProperty, array $properties): PropertyInterface
{
private function createMergedProperty(
PropertyInterface $compositionProperty,
array $properties,
array $propertyData
): PropertyInterface {
$mergedPropertySchema = new Schema();
$mergedClassName = sprintf('%s_Merged_%s', $this->schemaProcessor->getCurrentClassName(), uniqid());
$mergedClassName = sprintf(
'%s_Merged_%s', $this->schemaProcessor->getCurrentClassName(),
$propertyData['propertyData']['id'] ?? uniqid()
);

$mergedProperty = new Property('MergedProperty', $mergedClassName);

foreach ($properties as $property) {
Expand Down

0 comments on commit 0389cb1

Please sign in to comment.