Zufgriff von contao/dca/tl_content.php auf src/Service/RlService.php über System::get
Hallo,
wie kann ich von einer Klasse (class tl_content_rl extends Backend) in contao/dca/tl_content.php auf z.B ein Service
src/Service/RlService.php zugreifen.
PHP-Code:
public function __construct()
{
parent::__construct();
$this->rls = System::getContainer()->get(RlService::class);
}
Ich bekomme leider immer den Fehler
Code:
The "App\Service\RlService" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.
Dependency Injection über den Konstruktor geht in contao/dca/tl_content.php leider auch nicht, ansonsten kann ich RLService über DI verwenden, z.B: in Contao Modulen oder Content Elementen.
Ich habe den Service auch schon in config/services.yaml
Code:
services:
_defaults:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as controllers, event subscribers, etc. TODO disable this for performance reasons
App\:
resource: ../src
App\Controller\:
resource: ../src/Controller
tags: ['controller.service_arguments'] # Automatically injects dependencies in your controllers.
App\Service\RlService:
public: true
oder
Code:
services:
_defaults:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as controllers, event subscribers, etc. TODO disable this for performance reasons
public: true
App\:
resource: ../src
App\Controller\:
resource: ../src/Controller
tags: ['controller.service_arguments'] # Automatically injects dependencies in your controllers.
auf public stellen probiert, geht auch nicht.
Bitte um Hilfe, danke