Skip to content

Instantly share code, notes, and snippets.

@stijn1989
Created October 28, 2020 10:32
Show Gist options
  • Save stijn1989/ac3a698549ce81183936707f1f6ad8a9 to your computer and use it in GitHub Desktop.
Save stijn1989/ac3a698549ce81183936707f1f6ad8a9 to your computer and use it in GitHub Desktop.
why i love PHP :D
<?php
public function getOriginalEntity(string $entity_class_name) : ?Model
{
if(array_key_exists($entity_class_name, $this->entities)) {
$entity = $this->entities[ $entity_class_name ];
//copy properties from stdEntity to this entity
$stdEntity = $this->getEntity();
foreach($this->entityProperties[ $entity_class_name ] as $property) {
$entity->{$property} = $stdEntity->{$property};
}
return $entity;
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment