0

I'm trying to port a backend module from TYPO3 10 to TYPO3 11. I have already made dependency injection working moving the repository variable from protected to public, but this way of working is already deprecated and will be removed in TYPO3 12

I used the guide here to define a repository variable in my controller and instantiate it:

class ModuleConfController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
/**
 * @var \Aip\Bit3\Domain\Repository\AbstractRepository
 *
 */
private ?AbstractRepository $abstractRepository = null;

public function injectAbstractRepository(AbstractRepository $abstractRepository)
{
    $this->$abstractRepository = $abstractRepository;
}

I have also defined a Services.yaml file with this content:

services:
  _defaults:
    autowire: true
    autoconfigure: true
    public: false

  Aip\Bit3\:
    resource: '../Classes/*'
    exclude: '../Classes/Domain/Model/*'

The code seems to work since the inject injectAbstractRepository is called and the parameter is populated with an instance of the class AbstractRepository.

But instead of assinging the value to the class field it throws an exception

Object of class Aip\Bit3\Domain\Repository\AbstractRepository could not be converted to string

Can someone shed some light?

2
  • Do you have a stack trace? In which class/line is the error thrown? Commented Feb 14, 2023 at 17:28
  • 2
    You need to remove the $ and change the line to $this->abstractRepository Commented Feb 14, 2023 at 19:58

1 Answer 1

1

The comment made by Thomas Löffler solved the problem. I had improperly used cut and paste to write the wrong line and was mislead by the error message.

You need to remove the $ and change the line to $this->abstractRepository – Thomas Löffler

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.