【发布时间】:2019-04-05 12:47:46
【问题描述】:
我开始使用 Symfony4,当我尝试运行我的服务器时遇到以下错误:无法自动连接服务“App\Controller\CharacterInformation”:方法“__construct() 的参数“$region” " 是类型提示的“字符串”,你应该明确地配置它的值。
我如何实例化我的类:
/**
* @Route("/")
* @return Response
*/
function mainPage() {
$characterInformation = new CharacterInformation('eu');
return new Response($characterInformation->getCharacter());
}
CharacterInformation的构造函数:
/**
* @var int
*/
public function __construct(string $region) {
$this->apiInformation = new ApiContent($region);
}
ApiContent 的构造函数:
public function __construct(string $region) {
$apiToken = new ApiToken($region);
$this->token = $apiToken->getToken();
$this->region = $apiToken->getRegion();
}
感谢您的帮助
【问题讨论】: