Use the name and parent fields to generate the id.

{@inheritdoc}
434041
public function generate($document, ClassMetadata $class, DocumentManagerInterface $dm, $parent = null)
    {
        if (null === $parent) {
            $parent = $class->parentMapping ? $class->getFieldValue($document, $class->parentMapping) : null;
        }

        $name = $class->nodename ? $class->getFieldValue($document, $class->nodename) : null;
        $id = $class->getFieldValue($document, $class->identifier);

        if (empty($id)) {
            if (empty($name) && empty($parent)) {
                throw IdException::noIdentificationParameters($document, $class->parentMapping, $class->nodename);
            }

            if (empty($parent)) {
                throw IdException::noIdNoParent($document, $class->parentMapping);
            }

            if (empty($name)) {
                throw IdException::noIdNoName($document, $class->nodename);
            }
        }

        // use assigned ID by default
        if (empty($parent) || empty($name)) {
            return $id;
        }

        if ($exception = $class->isValidNodename($name)) {
            throw IdException::illegalName($document, $class->nodename, $name);
        }

        // determine ID based on the path and the node name
        return $this->buildName($document, $class, $dm, $parent, $name);
    }
1176851
protected function create_name() {
		$format  = '%s';
		$format .= str_repeat( '[%s]', ( count( $this->args->keys ) - 1 ) );

		return $this->create_id_name( $format );
	}
522340
private function idListGenerator(): \Generator
    {
        if (null === $this->ids) {
            $this->ids = $this->metaModel->getIdsFromFilter(null);
        }

        yield from $this->ids;
    }
406263
public function getIdField() {
	if(!empty($this->headers)
	&& !in_array($this->idField, $this->headers)) {
		throw new InvalidFieldException($this->idField);
	}

	return $this->idField;
}
1029474
private function generateHeaderName(array &$data, NodePath $nodePath, string $parentName, string $baseType)
    {
        if (empty($data['headerNames'])) {
            // write only once, because generateHeaderName may be called repeatedly
            if ($parentName != self::ARRAY_NAME) {
                // do not generate headers for arrays
                $headerName = $this->getSafeName($parentName);
                $headerName = $this->getUniqueName($baseType, $headerName);
                $data['headerNames'] = $headerName;
            } else {
                $data['headerNames'] = self::DATA_COLUMN;
            }
        }
        if ($data['nodeType'] == 'array') {
            // array node creates a new type and does not nest deeper
            $baseType = $baseType . '.' . $parentName;
            $parentName = '';
        }
        foreach ($data as $key => &$value) {
            if (is_array($value)) {
                $key = $this->decodeNodeName($key);
                if (!$parentName || (!empty($data[$key]['type']) && $data[$key]['type'] == 'parent')) {
                    // skip nesting if there is nowhere to nest (array or parent-type child)
                    $childName = $key;
                } else {
                    $childName = $parentName . '.' . $key;
                }
                $this->generateHeaderName($value, $nodePath->addChild($key), $childName, $baseType);
            }
        }
    }
914771
public function getID() {
		$parents = $this->getParents();
		$c = count($parents);

		if($c > 0) {
			$id = $parents[0].'-';
			for($i=1; $i<$c; $i++)
				$id .= $parents[$i].'-';
			$id .= $this->name;
			return $id;
		}
		else
			return $this->name;
	}
230311
public static function generate(string $inputName, array $typeFields, bool $generateIdField = false): string
    {
        $arguments = InputFieldsArgumentGenerator::generate($typeFields);
        $arguments = array_merge($arguments, RelationArgumentGenerator::generate($typeFields));
        if ($generateIdField) {
            $arguments = array_merge($arguments, IdArgumentGenerator::generate($typeFields));
        }

        if (count($arguments) < 1) {
            return '';
        }

        $query = sprintf('input %s {%s}', $inputName, implode(' ', $arguments));
        return $query;
    }
321838
protected function generateId()
    {
        $inputId = static::$idPrefix . $this->getName();
        if ($this->isMultiple()) {
            $inputId = "{$inputId}-{$this->instances}";
        }
        $this->setAttribute('id', $inputId);
        return $inputId;
    }
432686
def _create_id_field(new_class):
        """"""
        id_field = Auto(identifier=True)

        setattr(new_class, 'id', id_field)
        id_field.__set_name__(new_class, 'id')

        # Ensure ID field is updated properly in Meta attribute
        new_class.meta_.declared_fields['id'] = id_field
        new_class.meta_.id_field = id_field
595265
public function generate($document, ClassMetadata $class, DocumentManagerInterface $dm, $parent = null)
    {
        if (null === $parent) {
            $parent = $class->parentMapping ? $class->getFieldValue($document, $class->parentMapping) : null;
        }
        $repository = $dm->getRepository($class->name);
        if (!($repository instanceof RepositoryIdInterface)) {
            throw new IdException("ID could not be determined. Make sure the that the Repository '".ClassUtils::getClass($repository)."' implements RepositoryIdInterface");
        }

        $id = $repository->generateId($document, $parent);
        if (!$id) {
            throw new IdException('ID could not be determined. Repository was unable to generate an ID');
        }

        return $id;
    }
1172601
public function generate()
    {
        if ($this->parentIdentifier && !$this->parentObj) {
            $this->determineParentObj();
        }


        $i = 0;
        $ids = array();
        $parentField = $this->parentField;
        while ($i < $this->count) {
            $obj = Injector::inst()->create($this->subjectClass);
            if ($this->parentObj) {
                $obj->$parentField = $this->parentObj->ID;
            }
            $obj->fill(array(
                'only_empty' => $this->onlyEmpty,
                'include_relations' => $this->includeRelations,
                'download_images' => $this->downloadImages,
                'relation_create_limit' => $this->relationCreateLimit
            ));
            if ($this->parentObj) {
                $obj->write();
            }
            if ($this->isSiteTree) {
                $ids[] = $obj->write();
                $obj->publish("Stage", "Live");
            }
            $this->log("Created {$this->subjectClass} \"{$obj->getTitle()}\".");
            $i++;
        }

        return $ids;
    }
401269
public function getParentId()
    {
        // when this field will be introduced there will be no need to load from real article
        if (isset($this->oxorderarticles__oxartparentid) && $this->oxorderarticles__oxartparentid->value !== false) {
            return $this->oxorderarticles__oxartparentid->value;
        }

        $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
        $oArticle = oxNew(\OxidEsales\Eshop\Application\Model\Article::class);
        $sQ = "select oxparentid from " . $oArticle->getViewName() . " where oxid=" . $oDb->quote($this->getProductId());
        $this->oxarticles__oxparentid = new \OxidEsales\Eshop\Core\Field($oDb->getOne($sQ));

        return $this->oxarticles__oxparentid->value;
    }
505111
function GENERATE_VAR(name, spec, parent) {
  return GENERATE_DOC(spec.description + '\n'
    + '@property ' + name + '\n'
    + '@type ' + spec.type + '\n'
    + '@for ' + parent + '\n');
}
1349153
public function generateId()
    {
        $keys = $this->primaryKey();
        if (count($keys) === 1) {
            $i = rand(0, 9999);
            do {
                if (9999 == $i) {
                    $i = 0;
                }
                $i++;
                $id = time() . str_pad($i, 4, '0', STR_PAD_LEFT);
                $row = (new Query())->from(static::tableName())->where([$keys[0] => $id])->exists();
            } while ($row);
            return $id;
        } else {
            throw new NotSupportedException('"generateId" is not implemented.');
        }
    }
995451
def generate_id(self, obj):
        """"""
        object_type = type(obj).__name__.lower()
        return '{}_{}'.format(object_type, self.get_object_id(obj))
1335787
protected function _addIdField() {
        $params = array(
            'type' => 'numeric',
            'editable' => false,
            'visible' => false,
            //  next to being primary, an extra index key is also needed,
            //  to enable the flexibility to modify primary keys.
            'index' => true
        );

        $params['primary'] = !$this->_primaryKeyFieldIsPresent();

        $this['inputs'] = array('id' => $params) + $this['inputs'];
    }
1370020
private function determineIdStrategy()
    {
        if ($this->parentMapping && $this->nodename) {
            $this->setIdGenerator(self::GENERATOR_TYPE_PARENT);

            return;
        }
        if ($this->parentMapping) {
            $this->setIdGenerator(self::GENERATOR_TYPE_AUTO);

            return;
        }
        if ($this->getIdentifier()) {
            $this->setIdGenerator(self::GENERATOR_TYPE_ASSIGNED);

            return;
        }

        throw new MappingException(sprintf(
            'No id generator could be determined in "%s". Either map a parent and a nodename field and add values to them, or map the id field and configure a mapping strategy',
            $this->name
        ));
    }