Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
*/
class LiveComponentMetadataFactory
{
/** @var LiveComponentMetadata[] */
private array $liveComponentMetadata = [];

public function __construct(
private ComponentFactory $componentFactory,
private PropertyTypeExtractorInterface $propertyTypeExtractor,
Expand All @@ -33,12 +36,16 @@ public function __construct(

public function getMetadata(string $name): LiveComponentMetadata
{
if (isset($this->liveComponentMetadata[$name])) {
return $this->liveComponentMetadata[$name];
}

$componentMetadata = $this->componentFactory->metadataFor($name);

$reflectionClass = new \ReflectionClass($componentMetadata->getClass());
$livePropsMetadata = $this->createPropMetadatas($reflectionClass);

return new LiveComponentMetadata($componentMetadata, $livePropsMetadata);
return $this->liveComponentMetadata[$name] = new LiveComponentMetadata($componentMetadata, $livePropsMetadata);
}

/**
Expand Down