我正在尝试将用户的qr下载到PDF文件中,但是却收到未定义user.management.active的错误。我试图对其进行跟踪,但是我无法查明问题出在哪里。有人可以帮我吗?
错误:
[InvalidArgumentException: Identifier "user.management.active" is not defined. (uncaught exception) at /Library/WebServer/Documents/timekeeper_service/vendor/pimple/pimple/src/Pimple/Container.php line 96
这是我现在拥有的代码:
提供商
public function register(Container $container)
{
$container['user_management.active'] = $container->factory(function (Container $c) {
/** @var Jade $jade */
$jade = $c['jade_factory'];
$jade->view = 'cms/user_management/active_users';
/** @var UserManagementController $controller */
$controller = new UserManagementController();
$controller->setUserQuery(\UserQuery::create());
$controller->setView($jade);
return $controller;
});
用户管理
$user_management->get('/list/download_all_qr', 'user.management.active:qrToPdf');
控制器
public function qrToPdf(Application $app)
{
$users = $this->user_query->find();
$user_content = array();
foreach ($users as $user) {
$user_content[] = [
'name' => sprintf('%s, %s', $user->getLastName(), $user->getFirstName()),
'qr_code' => base64_encode(generateQrCode($user->getEmployeeId()))
];
}
/** @var Jade $jade */
$jade = $app['jade_factory'];
$jade->view = 'cms/user/download_all_qr';
$jade->with(['users' => $user_content]);
// Export to PDF
$mpdf = new \mPDF();
$mpdf->WriteHTML($jade->render());
$mpdf->Output('users_qr_'.Carbon::today()->toDateString().'.pdf', 'D');
}
答案 0 :(得分:0)
您已将工厂注册为user_management.active
,但随后尝试访问user.management.active
您必须将“用户”后的点更改为下划线或其他方式。
$user_management->get('/list/download_all_qr', 'user_management.active:qrToPdf');