---
title: "Breaking: #87305 - Use constructor injection in DataMapper"
manual: "TYPO3 Core Changelog"
version: "main"
permalink: "https://docs.typo3.org/permalink/changelog:breaking-87305"
source: "Changelog/10.0/Breaking-87305-UseConstructorInjectionInDataMapper.rst"
modified: "2026-09-14T09:47:36+00:00"
---

# Breaking: #87305 - Use constructor injection in DataMapper

See [forge#87305](https://forge.typo3.org/issues/87305)

## Description

Class `\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper` does no longer use setter injection. Instead, constructor injection is used.

## Impact

The method signature of the constructor changed. This means:

-   The amount of constructor arguments increased
-   The order of arguments possibly changed

## Affected Installations

All installations that create instances of the class `\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper` using `GeneralUtility::makeInstance` or `ObjectManager->get`.

## Migration

If possible, do not create instances yourself. Avoid `GeneralUtility::makeInstance` and `ObjectManager->get`. Instead use dependency injection, preferably constructor injection:

```php
public function __constructor(\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper $object)
{
    $this->property = $object;
}
```

If dependency injection is not possible, check the dependencies and instantiate objects via the object manager:

```php
$object = $objectManager->get(
    \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::class,
    $objectManager->get(\TYPO3\CMS\Extbase\Reflection\ReflectionService::class),
    // ...
);
```
