/**
  * handles running generators
  */
 public function generateAction()
 {
     $console = $this->getServiceLocator()->get('console');
     if (!$console instanceof \Zend\Console\Adapter\AdapterInterface) {
         throw new \RuntimeException('Cannot obtain console adapter, this action is only available from console');
     }
     $console->writeLine('Launching generators with params:');
     // creating params object
     $params = Params::factory($this->getRequest(), $this->getServiceLocator()->get('config')['VisioCrudModeler']['params']);
     // adding config
     $params->setParam('config', new Config($this->getServiceLocator()->get('config')['VisioCrudModeler']));
     // adding console adapter
     $params->setParam('console', $console);
     // fetching strategy through ServiceLocator
     $console->writeLine('fetching strategy');
     $generatorStrategy = new ExecuteGenerator($params);
     $generatorStrategy->setServiceLocator($this->getServiceLocator());
     $console->writeLine('strategy initialized, running generators');
     $generatorStrategy->generate();
 }
 /**
  * Ajax action for generating default structure
  */
 public function generateAction()
 {
     if ($this->getRequest()->isPost()) {
         $params = $this->getRequest()->getPost();
         $json = $params['data'];
     }
     $postParams = json_decode($json, true);
     if (empty($postParams)) {
         return $this->jsonResponse(array('success' => 0, 'message' => 'Json has not been properly decoded'));
     }
     try {
         $mergeDefaultParamsWithModeleted = array_merge($this->getServiceLocator()->get('config')['VisioCrudModeler']['params'], $postParams['params']);
         $params = Params::factory($this->getRequest(), $mergeDefaultParamsWithModeleted);
         $params->setParam('config', new Config($this->getServiceLocator()->get('config')['VisioCrudModeler']));
         $params->setParam('modeler', $postParams);
         $generatorStrategy = new WebGenerator($params);
         $generatorStrategy->setServiceLocator($this->getServiceLocator());
         $generatorStrategy->generate();
         return $this->jsonResponse(array('success' => 1, 'message' => 'Structure has been generated'));
     } catch (\Exception $e) {
         return $this->jsonResponse(array('success' => 0, 'message' => $e->getMessage()));
     }
 }