Skip to content

Commit

Permalink
add metadata id
Browse files Browse the repository at this point in the history
  • Loading branch information
priyadi committed Oct 14, 2024
1 parent 8ba43b6 commit b16bee0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ class: $targetClass,

// generate id

$id = hash('sha256', $sourceClass . $sourceProperty . $targetClass . $targetProperty);
$propertyMappingMetadataId = hash('sha256', $sourceClass . $sourceProperty . $targetClass . $targetProperty);

// instantiate property mapping

$propertyMapping = new PropertyMappingMetadata(
id: $id,
id: $propertyMappingMetadataId,
sourceProperty: $sourcePropertyMetadata->getReadMode() !== ReadMode::None ? $sourceProperty : null,
targetProperty: $targetProperty,
sourceTypes: $sourcePropertyMetadata->getTypes(),
Expand Down Expand Up @@ -163,7 +163,10 @@ class: $targetClass,
$effectivePropertiesToMap[] = $targetProperty;
}

$metadataId = hash('sha256', $sourceClass . $targetClass);

$objectToObjectMetadata = new ObjectToObjectMetadata(
id: $metadataId,
sourceClass: $sourceClass,
targetClass: $targetClass,
providedTargetClass: $providedTargetClass,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
* @param list<string> $sourceProperties List of the source properties. Used by `ObjectToObjectTransformer` to determine if a property is a dynamic property. A property not listed here is considered dynamic.
*/
public function __construct(
private string $id,
private string $sourceClass,
private string $targetClass,
private string $providedTargetClass,
Expand Down Expand Up @@ -123,6 +124,7 @@ public function withTargetProxy(
bool $constructorIsEager,
): self {
return new self(
id: $this->id,
sourceClass: $this->sourceClass,
targetClass: $this->targetClass,
providedTargetClass: $this->providedTargetClass,
Expand All @@ -149,6 +151,7 @@ public function withReasonCannotUseProxy(
string $reason,
): self {
return new self(
id: $this->id,
sourceClass: $this->sourceClass,
targetClass: $this->targetClass,
providedTargetClass: $this->providedTargetClass,
Expand All @@ -171,6 +174,11 @@ public function withReasonCannotUseProxy(
);
}

public function getId(): string
{
return $this->id;
}

/**
* @return class-string
*/
Expand Down

0 comments on commit b16bee0

Please sign in to comment.