Guest User

Untitled

a guest
May 20th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.20 KB | None | 0 0
  1. /*Not generating Doctrine_Record_Generator generations on every request
  2. ---------------------------------------------------------------------
  3.  
  4. In one of my Doctrine_Template_*, I recoded the ->generateClassFromTable() method.
  5. */
  6. public function generateClassFromTable(Doctrine_Table $table)
  7.     {
  8.         if(sfConfig::get('sf_environment') == 'prod')
  9.         {
  10.             $class = $table->getComponentName();
  11.             $record = new $class();
  12.         }
  13.         else
  14.         {
  15.             $definition = array();
  16.             $definition['columns'] = $table->getColumns();
  17.             $definition['tableName'] = $table->getTableName();
  18.             $definition['actAs'] = $table->getTemplates();
  19.             $definition['relations'] = $table->getRelations();
  20.            
  21. //this code is to generate the Plugin* file in the correct path
  22. //so any plugin model should add a package: information somewhere in the config
  23. //of the behavior.
  24. //This is not really related to our problem
  25.             if(isset($this->model['package']))
  26.             {
  27.                 $definition['package'] = $this->model['package'];
  28.                 $definition['package_custom_path'] = str_replace('.', DIRECTORY_SEPARATOR, $definition['package']);
  29.             }
  30.             $this->_options['generatePath'] = 'lib/model/doctrine';
  31.            
  32.             return $this->generateClass($definition);
  33.         }
  34.     }
Add Comment
Please, Sign In to add comment