protected function addDiscriminatorColumn(array $attributes): array
    {
        $discriminatorColumn = $this->entityMap->getDiscriminatorColumn();
        $entityClass = $this->entityMap->getClass();

        if (!array_key_exists($discriminatorColumn, $attributes)) {
            // Use key if present in discriminatorMap
            $map = $this->entityMap->getDiscriminatorColumnMap();

            $type = array_search($entityClass, $map);

            if ($type === false) {
                // Use entity FQCN if no corresponding key is set
                $attributes[$discriminatorColumn] = $entityClass;
            } else {
                $attributes[$discriminatorColumn] = $type;
            }
        }

        return $attributes;
    }