Ich habe folgende Controller:zend 2 einzuspritzen Controller: Abfangbare fatale Fehler: Argument 1 bis someController geben :: __ construct() muss eine Instanz ... keine gegeben
namespace Application\Controller;
use Application\Model\Person;
use Zend\Mvc\Controller\AbstractActionController;
use Application\Model\PersonTable;
class PersonController extends AbstractActionController
{
private $table;
public function __construct(PersonTable $table)
{
$this->table = $table;
}
// other methods
}
ich versucht zu tun hier Injektion durch Dokumentation folgende:
https://docs.zendframework.com/tutorials/getting-started/database-and-models/
In Modul/Anwendung/module.php ich habe diese Funktion:
public function getControllerConfig()
{
return [
'factories' => [
Controller\PersonController::class => function($container) {
return new Controller\PersonController(
$container->get(Model\PersonTable::class)
);
},
],
];
}
In Modul/Application/config/module.config.php ich geändert dies, so wäre es mein Controller haben:
'controllers' => array(
'invokables' => array(
'Application\Controller\Index' => 'Application\Controller\IndexController',
'Application\Controller\Person' => 'Application\Controller\PersonController'
),
),
ich die Controller-Methode von der Konsole aufrufen und den Fehler:
Behebbarer fataler Fehler: Argument 1 wurde an Application \ Controller \ PersonControl übergeben. ler :: __ construct() muss eine Instanz von Application \ Controller \ PersonTable sein, keine ne gegeben, in E: \ other \ dropbox \ Dropbox \ programavimas \ kodo aufgerufen pavydzziai \ htdoc s \ zend_2_staff_register \ vendor \ zendframework \ zendframework \ library \ Zend \ ServiceM anager \ AbstractPluginManager.php in Zeile 170 und definiert in E: \ andere \ dropbox \ Dro pbox \ programavimas \ kodo pavyzdziai \ htdocs \ zend_2_staff_register \ module \ Applicati auf \ src \ Application \ Controller \ PersonController.php in Zeile 12
Warum es nicht injiziert?