Hi,
I want to add a new directory context for a provider I am creating,
how do you add a new node to the .zfproject file?
What I need to end up with is:
...
<modelsDirectory>
<repositoryDirectory>
<repoFile repoName="User" />
</repositoryDirectory>
</modelsDirectory>
...
So I need to add the repository node when "zf create repository $name"
is called, so that I can add the reposFiles inside that directory
node.
I suppose essentially I want the command to have two contexts one that
creates the directory node and one that adds the files....
Below is what I have so far:
class Max_Tool_Project_Provider_MaxRepository extends
Zend_Tool_Project_Provider_Abstract
{
public function getContextClasses()
{
return array('Max_Tool_Project_Context_RepositoryDirectory');
}
protected static function
_getRepoDirectoryResource(Zend_Tool_Project_Profile $profile,
$moduleName = null)
{
$profileSearchParams = array();
if ($moduleName != null && is_string($moduleName)) {
$profileSearchParams = array('modulesDirectory',
'moduleDirectory' => array('moduleName' => $moduleName));
}
$profileSearchParams[] = 'modelsDirectory';
$profileSearchParams[] = 'repositoryDirectory';
return $profile->search($profileSearchParams);
}
public function create($name, $module=null)
{
$this->_loadProfile(self::NO_PROFILE_THROW_EXCEPTION);
var_dump(self::_getRepoDirectoryResource($this->_loadedProfile,
$module));
// create the directory at this point if it is not found???
}
}
class Max_Tool_Project_Context_RepositoryDirectory extends
Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_filesystemName = 'Repository';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'RepositoryDirectory';
}
}
--
------------
http://www.thepopeisdead.com