protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var $doctrine \Doctrine\Common\Persistence\ManagerRegistry */
     $doctrine = $this->getContainer()->get('doctrine');
     /** @var EntityManager $em */
     $em = $doctrine->getManager($input->getOption('em'));
     $generator = new GeneratorService();
     $generator->setAnnotationReader(new AnnotationReader());
     $generator->setTwigEngine($this->getContainer()->get('twig'));
     $filteredClassList = ExtJSModelsSaver::filterClassList($em, $em->getConfiguration()->getMetadataDriverImpl()->getAllClassNames());
     (new ExtJSModelsSaver())->setDirToSaveGeneratedModels($input->getArgument('target-dir'))->setGenerator($generator)->setEntityManager($em)->init()->addEntitiesToGenerate($filteredClassList)->run();
 }
 protected function setUp()
 {
     parent::setUp();
     static::$kernel = static::createKernel();
     static::$kernel->boot();
     $this->setEntityManager(self::$kernel->getContainer()->get('doctrine')->getManager());
     $this->generator = new GeneratorService();
     $this->generator->setAnnotationReader(new AnnotationReader());
     $this->generator->setTwigEngine(self::$kernel->getContainer()->get('twig'));
     $this->dirWithGeneratedModels = __DIR__ . '/generated_models';
     $this->predefinedModelSaver = (new ExtJSModelsSaver())->setEntityManager($this->em)->setGenerator($this->generator)->setDirToSaveGeneratedModels($this->dirWithGeneratedModels);
     self::$fullClassNamesList = $this->em->getConfiguration()->getMetadataDriverImpl()->getAllClassNames();
 }
 /**
  * @throws \LogicException
  */
 public function run()
 {
     $this->checkInitialization();
     $fs = new Filesystem();
     $fs->remove($this->dirToSaveGeneratedModels);
     $fs->mkdir($this->dirToSaveGeneratedModels);
     if (count($this->entityClassNamesList) === 0) {
         throw new \LogicException("Список с классами сущностей пуст. Задайте список методами ExtJSModelsSaver::addEntitiesToGenerate, ExtJSModelsSaver::addEntityClassToGenerate", self::ERR_LIST_WITH_CLASSES_IS_EMPTY);
     }
     foreach ($this->entityClassNamesList as $className) {
         $dir = null;
         $shortModelName = null;
         $this->parseModelClassToGetDirAndShortNameOfModel($className, $dir, $shortModelName);
         $fs->mkdir($dir);
         $dataToSave = $this->generator->generateMarkupForEntity($className);
         file_put_contents($dir . '/' . $shortModelName . '.js', $dataToSave);
     }
 }
 public function testReferenceDocument()
 {
     $this->service->generateMarkupForEntity('Test\\TestBundle\\Document\\Client');
     $associations = array();
     foreach ($this->twigEngine->renderParameters['associations'] as $assoc) {
         $associations[$assoc['name']] = $assoc;
     }
     $this->assertEquals('Test.document.Order', $associations['orders']['model']);
     $this->assertEquals('orders', $associations['orders']['name']);
     $this->assertEquals('ReferenceMany', $associations['orders']['type']);
     $this->service->generateMarkupForEntity('Test\\TestBundle\\Document\\Order');
     $associations = array();
     foreach ($this->twigEngine->renderParameters['associations'] as $assoc) {
         $associations[$assoc['name']] = $assoc;
     }
     $this->assertEquals('Test.document.Client', $associations['client']['model']);
     $this->assertEquals('client', $associations['client']['name']);
     $this->assertEquals('ReferenceOne', $associations['client']['type']);
 }
 public function testGenerateRemotingApi()
 {
     $this->service->setRemotingBundles(array('TestBundle' => 'Test\\TestBundle\\TestTestBundle'));
     $api = $this->service->generateRemotingApi();
     $this->assertSame(array('Test.TestBundle' => array('Test' => array(array('name' => 'test', 'len' => 0), array('name' => 'test2', 'len' => 1), array('name' => 'testRequestParam', 'len' => 1)))), $api);
 }