Daniel Siepmann - Coding is Art

Blog Post

Inject TypoScript Settings

Published: , Updated:

Tested with TYPO3: 9 LTS, 8 LTS

Topics: typo3


Sometimes you need settings like TypoScript in a class which is not your controller. Inside a controller, the Extbase framework already injects the settings for you, so you are able to access them under $this->settings.

In all other classes it’s easy to let Extbase inject the settings for you. Just include the following code, and make sure you instantiate the class via \TYPO3\CMS\Extbase\Object\ObjectManager instead of \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance().

namespace DS\ExampleExtension\Service;

 * Copyright (C) 2015  Daniel Siepmann <coding@daniel-siepmann.de>
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.

use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;

 * Example Service to demonstrate inject of settings.
class SomeService
     * @var array
    protected $settings = [];

     * Inject settings via ConfigurationManager.
     * @param ConfigurationManagerInterface $configurationManager
    public function injectConfigurationManager(ConfigurationManagerInterface $configurationManager)
        $this->settings = $configurationManager->getConfiguration(

This will use Extbase inject mechanism of ObjectManager to inject the ConfigurationManager. Instead of persisting this instance as a property, we just use it to fetch the settings and persist them instead. As most developers are used to $this->settings from Controllers, I’m using the same convention in my classes.

This way the settings are available as a property in the class without any further work.

Just make sure you are using the \TYPO3\CMS\Extbase\Object\ObjectManager as pointed out above. It’s really important, as only this class will process the injects. \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance() doesn’t support this feature.

Further reading

Check out the post about TYPO3 (Extbase) Injection.

Check out the post with concrete examples for Dependency Injection to find out how this will work since TYPO3 v10 LTS.