Skip to content

Commit

Permalink
working on adding field parameters to constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
dcarbone committed Jan 7, 2025
1 parent 2da2e15 commit ca2b376
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
13 changes: 8 additions & 5 deletions template/versions/types/class_resource_container.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,18 @@

/**
* <?php echo $type->getClassName(); ?> Constructor
* @param null|array|<?php echo $versionContainedTypeInterface->getFullyQualifiedName(true); ?> $data
* @param null|array $data
* @param null|<?php echo $versionContainedTypeInterface->getFullyQualifiedName(true); ?> $containedType
*/
public function __construct(null|array|<?php echo $versionContainedTypeInterface->getEntityName(); ?> $data = null)
public function __construct(null|array $data = null,
null|<?php echo $versionContainedTypeInterface->getEntityName(); ?> $containedType = null)
{
if (null === $data || [] === $data) {
if (null !== $containedType) {
$this->setContainedType($containedType);
return;
}

if ($data instanceof <?php echo $versionContainedTypeInterface->getEntityName(); ?>) {
$this->setContainedType($data);
if (null === $data || [] === $data) {
return;
}

Expand All @@ -70,6 +72,7 @@ public function __construct(null|array|<?php echo $versionContainedTypeInterface
$this->_addFHIRComment($data[<?php echo PHPFHIR_CLASSNAME_CONSTANTS; ?>::JSON_FIELD_FHIR_COMMENTS]);
}
}

$class = <?php echo $versionTypeMapClass->getEntityName(); ?>::getContainedTypeClassNameFromArray($data);
$this->setContainedType(new $class($data[$class::FHIR_TYPE_NAME]));
}
Expand Down
21 changes: 18 additions & 3 deletions template/versions/types/methods/constructor.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,26 @@ public function __construct(<?php echo TypeHintUtils::typeSetterTypeHint($versio
$valuePropertyType = $valueProperty->getValueFHIRType();
$valuePropertyPrimitiveType = $valuePropertyType->getPrimitiveType();
?>

/**
* <?php echo $typeClassName; ?> Constructor
* @param <?php echo TypeHintUtils::typeSetterTypeHint($version, $valuePropertyType, true); ?>|<?php echo $valuePropertyType->getClassName(); ?>|array $data
*/
public function __construct(<?php echo TypeHintUtils::propertySetterTypeHint($version, $valueProperty, true); ?>|array $data = null)
* @param null|array $data
* @param <?php echo TypeHintUtils::typeSetterTypeHint($version, $valuePropertyType, true); ?>|<?php echo $valuePropertyType->getClassName(); ?> $value
<?php foreach($type->getAllPropertiesIndexedIterator() as $property) :
if ($property->isValueProperty()) {
continue;
}
?>
* @param null|<?php echo TypeHintUtils::propertySetterTypeHint($version, $property, true); ?> $<?php echo $property->getName(); ?>

<?php endforeach; ?> */
public function __construct(null|array $data = null,
<?php echo TypeHintUtils::propertySetterTypeHint($version, $valueProperty, true); ?> $value = null<?php foreach($type->getAllPropertiesIndexedIterator() as $property) :
if ($property->isValueProperty()) {
continue;
}
?>,
<?php echo TypeHintUtils::propertySetterTypeHint($version, $property, true); ?> $<?php echo $property->getName(); ?> = null<?php endforeach; ?>)
{
if (null === $data) {
return;
Expand Down

0 comments on commit ca2b376

Please sign in to comment.