/**
  * generates code for base model and saves in file (overrides file if exists)
  *
  * @param DataSetDescriptorInterface $dataSet
  * @return string name of generated class
  */
 protected function generateBaseModel(DataSetDescriptorInterface $dataSet)
 {
     $name = $dataSet->getName();
     $className = "Base" . $this->underscoreToCamelCase->filter($name);
     $namespace = $this->params->getParam("moduleName") . "\\Model\\BaseModel";
     $fullClassName = '\\' . $namespace . '\\' . $className;
     $class = new ClassGenerator();
     $class->setName($className);
     $class->setNamespaceName($namespace);
     $class->setExtendedClass($this->baseModelParent);
     foreach ($this->baseModelUses as $use) {
         $class->addUse($use);
     }
     $this->addEventsMethods($class);
     foreach ($dataSet->listFields() as $name) {
         $column = $dataSet->getFieldDescriptor($name);
         $this->generateColumnRelatedElements($class, $column);
     }
     $file = new FileGenerator();
     $docBlock = new \Zend\Code\Generator\DocblockGenerator(sprintf($this->codeLibrary()->get('model.generatedConfigDescription'), $name));
     $docBlock->setTag(new GenericTag('author', $this->params->getParam('author')))->setTag(new GenericTag('project', $this->params->getParam('project')))->setTag(new GenericTag('license', $this->params->getParam('license')))->setTag(new GenericTag('copyright', $this->params->getParam('copyright')));
     $class->setDocBlock($docBlock);
     $file->setClass($class);
     $modelClassFilePath = $this->moduleRoot() . "/src/" . $this->params->getParam("moduleName") . "/Model/BaseModel/" . $className . ".php";
     file_put_contents($modelClassFilePath, $file->generate());
     return $fullClassName;
 }
 /**
  * generates file with target grid (if not exists yet)
  *
  * @param DataSetDescriptorInterface $dataSet
  * @param string $extends
  *            base class for grid
  * @return string full name of generated class
  */
 protected function generateGrid(DataSetDescriptorInterface $dataSet, $extends)
 {
     $name = $dataSet->getName();
     $className = $this->underscoreToCamelCase->filter($name) . "Grid";
     $namespace = $this->params->getParam("moduleName") . "\\Grid";
     $fullClassName = '\\' . $namespace . '\\' . $className;
     $gridClassFilePath = $this->moduleRoot() . "/src/" . $this->params->getParam("moduleName") . "/Grid/" . $className . ".php";
     if (file_exists($gridClassFilePath)) {
         return $fullClassName;
     }
     $class = new ClassGenerator();
     $class->setName($className);
     $class->setNamespaceName($namespace);
     $class->setExtendedClass($extends);
     $file = new FileGenerator();
     $docBlock = new \Zend\Code\Generator\DocblockGenerator(sprintf($this->codeLibrary()->get('grid.standardConfigDescription'), $name));
     $docBlock->setTag(new GenericTag('author', $this->params->getParam('author')))->setTag(new GenericTag('project', $this->params->getParam('project')))->setTag(new GenericTag('license', $this->params->getParam('license')))->setTag(new GenericTag('copyright', $this->params->getParam('copyright')));
     $file->setClass($class)->setDocBlock($docBlock);
     file_put_contents($gridClassFilePath, $file->generate());
     return $fullClassName;
 }
 /**
  * returns values map for template according to given dataSet
  *
  * @param DataSetDescriptorInterface $dataSet
  * @return array
  */
 protected function prepareTemplateSubstitutionData(DataSetDescriptorInterface $dataSet)
 {
     $name = $dataSet->getName();
     $data = array();
     if ($this->params->getParam('runtimeConfiguration') instanceof Config) {
         $runtime = (array) $this->params->getParam('runtimeConfiguration')->toArray();
         $data['%table%'] = $runtime['model'][$name]['table'];
         $data['%model%'] = $runtime['model'][$name]['model'];
         $data['%form%'] = $runtime['form'][$name]['form'];
         $data['%filter%'] = $runtime['inputFilter'][$name]['filter'];
         $data['%grid%'] = $runtime['form'][$name]['grid'];
         $data['%filteredModule%'] = strtolower($this->params->getParam('moduleName'));
         $data['%filteredController%'] = strtolower($this->camelCasToSeparator->filter($this->underscoreToCamelCase->filter($dataSet->getName())));
         $data['%adapterKey%'] = $this->params->getParam('adapterServiceKey');
     }
     return $data;
 }