php - Use Doctrine ArrayCollection in symfony custom command -
i use arraycollection
in custom symfony command.
but way throwing error
the class 'doctrine\common\collections\arraycollection' not found in chain configured namespaces appbundle\entity
my command
<?php namespace appbundle\command; use symfony\bundle\frameworkbundle\command\containerawarecommand; use symfony\component\console\input\inputargument; use symfony\component\console\input\inputinterface; use symfony\component\console\input\inputoption; use symfony\component\console\output\outputinterface; use doctrine\common\collections\arraycollection; use appbundle\entity\gameworld; class mycommand extends containerawarecommand { protected function configure() { $this ->setname('get:gw') ->setdescription('populate gameworld') ; } protected function execute(inputinterface $input, outputinterface $output) { $em = $this->getcontainer()->get('doctrine')->getmanager(); $output->writeln('<info>get current gameworlds</info>'); $gws = $em->getrepository('appbundle:gameworld')->findall(); $gws = new arraycollection($gws); /* rest of command */ } }
i tried new \doctrine\common\collections\arraycollection($gws);
but error still there.
hope may help.
you tries create instance of arraycollection in gameworld constructor(or somewhere in related entities constructors), did not imported use doctrine\common\collections\arraycollection; call. try check appbundle\entity\gameworld class , related entities occurances of arraycollection , check whether import inside classes.
Comments
Post a Comment