调用我创建的自定义函数时出错:
namespace App\Jobs\Device;
class UpdateUserReference {
public $installationReference;
public $userReference;
// assign payload data and installation id received to command
function __construct($bodyContent) {
$this->installationReference = $bodyContent["installationReference"];
$this->userReference = $bodyContent["userReference"];
}
}
类App \ Jobs \ Device \ UpdateUserReference中无法解析的依赖项解析[参数#0 [$ bodyContent]]
奇怪的是我之前从未遇到过错误,而且我创建的函数与所有其他情况完全相同。我提供的bodyContent变量有什么问题?
在以下内容中调用该函数:
public function update(Request $request) {
// Get payload from request
$bodyContent = json_decode($request->getContent(), true);
$action = $bodyContent["action"];
$installationReference = $bodyContent["installationReference"];
switch($action) {
case 'userReference':
$updateUserReference = new UpdateUserReference($bodyContent);
$result = $this->commandBus->execute($updateUserReference);
break;
}
if (!empty($result)) {
$response = [
'error' => [
'code' => 400,
'message' => "Update Error"
]
];
return $this->setStatusCode(400)->respond($response);
}
$response = [
'data' => [
'installationReference' => $installationReference
]
];
return $this->setStatusCode(201)->respond($response);
}