Content
As I said it is not clear way but it is so simply that I didn't want to invest much time to find solvetion and used this hack.
At beginning
This approach is bad but it is trivial and works. First I thought about a way how to inject/override by my implementation but if I stood before "I need only change location where objects will be generated..."Use Case
For example - your project's 'models' directory has different structure and you must remove each generated model's php file to your specific directory.Standart directory layout
If you use command"zf create model ItemModel". ItemModel file will be generated by default in directory 'models'. ----models |--DbTable |--ItemModel.php
Specific directory layout
We want to generate model class in subdirectory 'Domain'. That's all.----models
|--DbTable
|--Domain
|--ItemModel.php
Solvetion
We must find directory '%ZF_HOME%\library\Zend\Tool\Project\Context\Zf\'. There are lot of sources which define how to generate/utilizing project's entities. We look for ModelsDirectory.php and replace location in$_filesystemName attribute (default 'models') by 'models/Domain'. class Zend_Tool_Project_Context_Zf_ModelsDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_filesystemName = 'models/Domain';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'ModelsDirectory';
}
}
Next you must change filename mask in order to be correctly generated. You must find entity file.... ModelFile.php and there is method getContents. Now we can generate model entities in Domain subdirectory with correct name - %APP_NAME%_Model_Domain_%FILE_NAME%
class Zend_Tool_Project_Context_Zf_ModelFile extends Zend_Tool_Project_Context_Zf_AbstractClassFile
{
public function getContents()
{
$className = $this->getFullClassName($this->_modelName, 'Model_Domain');
$codeGenFile = new Zend_CodeGenerator_Php_File(array(
'fileName' => $this->getPath(),
'classes' => array(
new Zend_CodeGenerator_Php_Class(array(
'name' => $className,
))
)
));
return $codeGenFile->generate();
}
}
Summary
If I checked .zfproject.xml I didn't find any problem because xml doesn't describe real filesystem structure. XML file is not concrete and don't depend at location where item (model, controller, action) will be generated .As I said it is not clear way but it is so simply that I didn't want to invest much time to find solvetion and used this hack.
Komentáře