private function createEntityWithKey(EntityResult $obj_result)
{
// Get the full key path
$arr_key_path = $obj_result->getEntity()->getKey()->getPathElementList();
// Key for 'self' (the last part of the KEY PATH)
/* @var $obj_path_end \google\appengine\datastore\v4\Key\PathElement */
$obj_path_end = array_pop($arr_key_path);
if ($obj_path_end->getKind() == $this->obj_schema->getKind()) {
$bol_schema_match = TRUE;
$obj_gds_entity = $this->obj_schema->createEntity();
} else {
$bol_schema_match = FALSE;
$obj_gds_entity = (new \GDS\Entity())->setKind($obj_path_end->getKind());
}
// Set ID or Name (will always have one or the other)
if ($obj_path_end->hasId()) {
$obj_gds_entity->setKeyId($obj_path_end->getId());
} else {
$obj_gds_entity->setKeyName($obj_path_end->getName());
}
// Ancestors?
$int_ancestor_elements = count($arr_key_path);
if ($int_ancestor_elements > 0) {
$arr_anc_path = [];
foreach ($arr_key_path as $obj_kpe) {
$arr_anc_path[] = ['kind' => $obj_kpe->getKind(), 'id' => $obj_kpe->hasId() ? $obj_kpe->getId() : null, 'name' => $obj_kpe->hasName() ? $obj_kpe->getName() : null];
}
$obj_gds_entity->setAncestry($arr_anc_path);
}
// Return whether or not the Schema matched
return [$obj_gds_entity, $bol_schema_match];
}