/**
* Create a fully qualified Key path
*
* @equivalent ProtoBuf::configureKey() ?
*
* @param Entity $obj_gds_entity
* @param bool $bol_first_node
* @return array
* @throws \Exception
*/
private function buildKeyPath(Entity $obj_gds_entity, $bol_first_node = TRUE)
{
$str_kind = $obj_gds_entity->getKind();
if (null === $str_kind) {
if ($bol_first_node) {
$str_kind = $this->obj_schema->getKind();
} else {
throw new \Exception('Could not build full key path, no Kind set on (nth node) GDS Entity');
}
}
// Build the first node in the Key Path from this entity
$arr_full_path = [$this->createKeyPathElement(['kind' => $str_kind, 'id' => $obj_gds_entity->getKeyId(), 'name' => $obj_gds_entity->getKeyName()])];
// Add any ancestors to the Key Path
$mix_ancestry = $obj_gds_entity->getAncestry();
if (is_array($mix_ancestry)) {
foreach ((array) $obj_gds_entity->getAncestry() as $arr_ancestor_element) {
array_unshift($arr_full_path, $this->createKeyPathElement($arr_ancestor_element));
}
} elseif ($mix_ancestry instanceof Entity) {
$arr_full_path = array_merge($this->buildKeyPath($mix_ancestry, FALSE), $arr_full_path);
}
return $arr_full_path;
}