Example #1
0
 public function __construct(Table $table, Cluster $cluster, $outputFilename = null, array $options = array())
 {
     $this->_table = $table;
     $this->outputFilename = $outputFilename;
     if (!empty($options)) {
         $this->setOptions($options);
     }
     $table = $this->getTable();
     $alias = $this->getOption('alias', null);
     $aliasAsCamelCase = implode('', array_map('ucfirst', explode('_', $alias)));
     if ($alias) {
         $className = $aliasAsCamelCase . 'Cond';
         $extendedClassName = $table->getNameAsCamelCase() . 'Cond';
     } else {
         $className = $table->getNameAsCamelCase() . 'Cond';
         $extendedClassName = 'Abstract' . $table->getNameAsCamelCase() . 'Cond';
     }
     Log::info('Generate part cond ' . $table->getName());
     $file = new FileGenerator();
     $this->setFile($file);
     $class = new ClassGenerator();
     $file->setClass($class);
     $this->_runPlugins(self::PART_FRONT_COND, self::RUNTIME_PRE);
     $class->setNamespaceName('Model\\Cond');
     $class->setName($className);
     $class->setExtendedClass($extendedClassName);
     $this->_runPlugins(self::PART_FRONT_COND, self::RUNTIME_POST);
     if ($filename = $this->getOutputFilename()) {
         $result = file_put_contents($filename, $file->generate());
         if (!$result) {
             throw new ErrorException('File is not writeable: ' . $filename);
         }
     }
 }
Example #2
0
 public function __construct(Table $table, Cluster $cluster, $outputFilename = null, array $options = array())
 {
     if (!empty($options)) {
         $this->setOptions($options);
     }
     Log::info('Generate part mode ' . $table->getName());
     $this->_table = $table;
     $file = new FileGenerator();
     $this->setFile($file);
     $file->setNamespace('Model');
     $class = new ClassGenerator();
     $file->setClass($class);
     $file->addUse('Model\\Result\\Result');
     $file->addUse('Model\\Entity\\' . $table->getNameAsCamelCase() . 'Entity');
     $file->addUse('Model\\Cond\\' . $table->getNameAsCamelCase() . 'Cond', 'Cond');
     $file->addUse('Model\\Cond\\AbstractCond');
     $file->addUse('Model\\Collection\\' . $table->getNameAsCamelCase() . 'Collection');
     $this->_runPlugins(self::PART_MODEL, self::RUNTIME_PRE);
     $class->setName('Abstract' . $table->getNameAsCamelCase() . 'Model');
     if ($table->isTree() && $this->hasPlugin('Tree', AbstractPart::PART_MODEL)) {
         $class->setExtendedClass('\\Model\\Mysql\\TreeModel');
     } else {
         $class->setExtendedClass('\\Model\\Mysql\\AbstractModel');
     }
     $class->setAbstract(true);
     $this->_runPlugins(self::PART_MODEL, self::RUNTIME_POST);
     if ($outputFilename) {
         file_put_contents($outputFilename, $file->generate());
     }
 }
Example #3
0
 protected function _runPlugins($part, $runTime)
 {
     foreach ($this->getPlugins($part) as $plugin) {
         if ($plugin instanceof $part) {
             $args = array($this);
             $_args = func_get_args();
             if (func_num_args() > 2) {
                 for ($i = 2; $i < func_num_args(); $i++) {
                     $args[] = $_args[$i];
                 }
             }
             Log::info("Run plugin " . self::_getPluginPath($part, $plugin) . '::' . $runTime);
             call_user_func_array(array($plugin, $runTime), $args);
         }
     }
 }
Example #4
0
 public function __construct(Table $table, Schema $cluster, $outputFilename = null)
 {
     Log::info('Generate part entity ' . $table->getName());
     $this->_table = $table;
     $file = new \Model\Code\Generator\FileGenerator();
     $class = new \Zend\Code\Generator\ClassGenerator();
     $file->setClass($class);
     $this->setFile($file);
     $this->_runPlugins(self::PART_ENTITY_ABSTRACT, self::RUNTIME_PRE);
     $class->setName($table->getNameAsCamelCase() . 'EntityAbstract');
     $class->setExtendedClass('\\Model\\Entity');
     $this->_runPlugins(self::PART_ENTITY_ABSTRACT, self::RUNTIME_POST);
     if ($outputFilename) {
         file_put_contents($outputFilename, $file->generate());
     }
 }
Example #5
0
 public function __construct(Table $table, Cluster $cluster, $outputFilename = null)
 {
     Log::info('Generate part front collection ' . $table->getName());
     $this->_table = $table;
     $file = new \Model\Code\Generator\FileGenerator();
     $this->setFile($file);
     $class = new \Zend\Code\Generator\ClassGenerator();
     $file->setClass($class);
     $this->_runPlugins(self::PART_FRONT_COLLECTION, self::RUNTIME_PRE);
     $class->setNamespaceName('Model\\Collection');
     $class->setName($table->getNameAsCamelCase() . 'Collection');
     $class->setExtendedClass('Abstract' . $table->getNameAsCamelCase() . 'Collection');
     $this->_runPlugins(self::PART_FRONT_COLLECTION, self::RUNTIME_POST);
     if ($outputFilename) {
         file_put_contents($outputFilename, $file->generate());
     }
 }
Example #6
0
 public function __construct(Table $table, Cluster $cluster, $outputFilename = null)
 {
     Log::debug('Generate part list ' . $table->getName());
     $this->_table = $table;
     $file = new FileGenerator();
     $this->setFile($file);
     $class = new ClassGenerator();
     $file->setClass($class);
     $file->setNamespace('Model\\Collection');
     //$file->setUse('Model\ResultList');
     $this->_runPlugins(self::PART_COLLECTION, self::RUNTIME_PRE);
     $class->setName('Abstract' . $table->getNameAsCamelCase() . 'Collection');
     $class->setExtendedClass('AbstractCollection');
     $class->setAbstract(true);
     $this->_runPlugins(self::PART_COLLECTION, self::RUNTIME_POST);
     if ($outputFilename) {
         file_put_contents($outputFilename, $file->generate());
     }
 }