/**
  * Tests DbDataSourceDescriptor->listGenerator()
  */
 public function testListGenerator()
 {
     $this->assertInstanceOf('\\Generator', $this->DbDataSourceDescriptor->listGenerator(), 'returning generator instance');
     foreach ($this->DbDataSourceDescriptor->listGenerator() as $key => $value) {
         $this->assertInternalType('string', $key, 'dataset name');
         $this->assertInstanceOf('\\VisioCrudModeler\\Descriptor\\Db\\DbDataSetDescriptor', $value, ' implementation of db dataset descriptor');
         $this->assertInstanceOf('\\VisioCrudModeler\\Descriptor\\DataSetDescriptorInterface', $value, ' implementation of dataset descriptor interface');
     }
 }
 public function controllerAction()
 {
     $config = $this->getServiceLocator()->get('config');
     $moduleName = $config['VisioCrudModeler']['params']['moduleName'];
     $modulePath = $config['VisioCrudModeler']['params']['modulesDirectory'];
     $db = $this->getServiceLocator()->get('Zend\\Db\\Adapter\\Adapter');
     $dataSourceDescriptor = new DbDataSourceDescriptor($db, 'K08_www_biedronka_pl');
     $listDataSets = $dataSourceDescriptor->listDataSets();
     $filter = new \Zend\Filter\Word\UnderscoreToCamelCase();
     foreach ($listDataSets as $d) {
         $className = $filter->filter($d) . 'Controller';
         $file = new FileGenerator();
         $file->setFilename($className);
         $file->setNamespace($moduleName)->setUse('Zend\\Mvc\\Controller\\AbstractActionController');
         $foo = new ClassGenerator();
         $docblock = DocBlockGenerator::fromArray(array('shortDescription' => 'Sample generated class', 'longDescription' => 'This is a class generated with Zend\\Code\\Generator.', 'tags' => array(array('name' => 'version', 'description' => '$Rev:$'), array('name' => 'license', 'description' => 'New BSD'))));
         $foo->setName($className);
         $foo->setExtendedClass('Base' . $className);
         $foo->setDocblock($docblock);
         $file->setClass($foo);
         echo '<pre>';
         echo htmlentities($file->generate());
         echo '</pre>';
         $fileView = new FileGenerator();
         $body = "echo '{$className}';";
         $fileView->setBody($body);
         echo '<pre>';
         echo htmlentities($fileView->generate());
         echo '</pre>';
     }
     echo '<hr />';
     foreach ($listDataSets as $d) {
         $className = 'Base' . $filter->filter($d) . 'Controller';
         $fileBase = new FileGenerator();
         $fileBase->setFilename($className);
         $fileBase->setNamespace($moduleName)->setUse('Zend\\Mvc\\Controller\\AbstractActionController');
         $fooBase = new ClassGenerator();
         $docblockBase = DocBlockGenerator::fromArray(array('shortDescription' => 'Sample generated class', 'longDescription' => 'This is a class generated with Zend\\Code\\Generator.', 'tags' => array(array('name' => 'version', 'description' => '$Rev:$'), array('name' => 'license', 'description' => 'New BSD'))));
         $fooBase->setName($className);
         $index = new MethodGenerator();
         $index->setName('indexAction');
         $create = new MethodGenerator();
         $create->setName('createAction');
         $read = new MethodGenerator();
         $read->setName('readAction');
         $update = new MethodGenerator();
         $update->setName('updateAction');
         $delete = new MethodGenerator();
         $delete->setName('deleteAction');
         $fooBase->setExtendedClass('AbstractActionController');
         //$fooBase->set
         $fooBase->setDocblock($docblock);
         $fooBase->addMethodFromGenerator($index);
         $fooBase->addMethodFromGenerator($create);
         $fooBase->addMethodFromGenerator($read);
         $fooBase->addMethodFromGenerator($update);
         $fooBase->addMethodFromGenerator($delete);
         $fileBase->setClass($fooBase);
         echo '<pre>';
         echo htmlentities($fileBase->generate());
         echo '</pre>';
     }
     exit;
 }
 /**
  * handles modeler interface
  */
 public function modelerAction()
 {
     $adapter = $this->getDbAdapter();
     $dataSourceDescriptor = new DbDataSourceDescriptor($adapter);
     return array('tables' => $dataSourceDescriptor->listDataSets(), 'dataSourceDescriptor' => $dataSourceDescriptor, 'underscoreToCamelCase' => new \Zend\Filter\Word\UnderscoreToCamelCase(), 'config' => $this->getServiceLocator()->get('config')['VisioCrudModeler']['params']);
 }