심포니 2 명령 클래스를 사용하여 배치 파일을 작성합니다. 난 번들 내부의 컨트롤러에서 DB를 다루는 기능이symfony 2의 명령 클래스에서 클래스 컨트롤러 기능을 사용하는 방법은 무엇입니까?
class SubmitDisclosureController extends FOSRestController implements MEAuthController { ... public function discDetails($discId) {
$emr = $this->getDoctrine()->getEntityManager();
class BatchJobCommand extends Command
{
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln([
'User Creator',
'============',
'',
]);
// retrieve the argument value using getArgument()
$output->writeln('First batch job')
$disc = new SubmitDisclosureController();
$disc->discDetails('42094');
`
다음과 같다 명령 src/AppBundle/Command/BatchJobCommand.php
에서이 호출하고
, 그것을 PHP Fatal error: Call to a member function has() on null in C:\xampp\htdocs\GR\ vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Controller\Controller. php on line 288
명령 클래스에서 컨트롤러의 기능을 호출하여 코드를 재사용 할 수 있습니까?
는 당신이 필요로 서비스 사실이다 컨트롤러와 명령 모두에서 사용할 수 있습니다. –
@MateiMihai 네, 맞습니다. 그러나 이러한 변화는 기존 기능에 영향을 미칠 것입니다. –