Open djungbluth opened 13 years ago
I'd like to propose a patch to enable support for pear-style model class naming:
Index: library/ZFDoctrine/Import/Builder.php =================================================================== --- library/ZFDoctrine/Import/Builder.php (revision 28631) +++ library/ZFDoctrine/Import/Builder.php (working copy) @@ -34,6 +34,10 @@ $pos = strpos($originalClassName, 'Model_'); $originalClassName = substr($originalClassName, $pos+6); + if ($this->_pearStyle) { + $originalClassName = str_replace('_', '/', $originalClassName); + } + $file = $originalClassName . $this->_suffix; return $file; @@ -49,7 +53,11 @@ $className = $definition['tableClassName']; $pos = strpos($className, "Model_"); $fileName = substr($className, $pos+6) . $this->_suffix; - $writePath = $path . DIRECTORY_SEPARATOR . $fileName; + if ($this->_pearStyle) { + $writePath = $path . DIRECTORY_SEPARATOR . str_replace('_', '/', $fileName); + } else { + $writePath = $path . DIRECTORY_SEPARATOR . $fileName; + } $content = $this->buildTableClassDefinition($className, $definition, $options); Index: library/ZFDoctrine/Import/Schema.php =================================================================== --- library/ZFDoctrine/Import/Schema.php (revision 28631) +++ library/ZFDoctrine/Import/Schema.php (working copy) @@ -91,7 +91,6 @@ public function getOptions() { $options = parent::getOptions(); - $options['pearStyle'] = false; $options['baseClassesDirectory'] = 'Base'; $options['baseClassPrefix'] = ''; $options['classPrefix'] = '';
By doing so, one can enable pearStyle in application config. In INI, for example:
resources.doctrine.generateModels.pearStyle = 1
Hi,
I'd like to integrate zf-doctrine into a ZF project with modules, but I'm stuck at the point when it comes to "generate-models-from-yaml".
Example: The schema file contains a definition for Default_Model_Mail_Template. I would expect the generated model file to be placed at
application/modules/default/models/Mail/Template.php
but instead,
application/modules/default/models/Mail_Template.php
is generated. I've tried to set resources.doctrine.generateModels.pearStyle = 1 in my application config but without effect (as it gets overwritten by some defaults in ZFDoctrine_Import_Schema).
Model loading is set to model_loading_zend.
I really need some assist, please. Thanks!