ZF-6755: Zend_Tool_Project_Provider_Controller refuses to create a controller in a module if a controller with the same name exists in default module

Issue Type: Bug Created: 2009-05-20T13:27:30.000+0000 Last Updated: 2012-02-10T09:00:58.000+0000 Status: Resolved Fix version(s): - 1.8.4 (23/Jun/09)

Reporter: C├ędric Floquet (ced-le-pingouin) Assignee: Satoru Yoshida (satoruyoshida) Tags: - Zend_Tool

Related issues: - ZF-6853



I just discovered Zend_Tool and I'm testing it right now.

I'm using modules in an existing project, so I tested this aspect too, and I hit a bug. Here's what I'm doing:

$ zf create project zf-site $ cd zf-site $ zf create module admin

Then, if i do:

$ zf create controller MyCtrlr 1 admin

It works, and successfully creates a MyCtrlr controller in the admin module, with an initial IndexAction method

But if i try:

$ zf create controller index 1 admin

It fails with the error "This project already has a controller named index"

The only index controller that exists is in the default module, so the creation of an index controller in the admin module should be accepted.

I'm new to the code of Zend_Tool, so I don't know what is done on purpose or is temporary, but I guess the error comes from line 141 (as of ZF 1.8.1) in Zend/Tool/Project/Provider/Controller.php :

141 if (self::hasResource($this->_loadedProfile, $name)) {

If I'm not mistaken, a 3rd parameter in hasResource() is accepted, giving the $module, so maybe the line should be:

141 if (self::hasResource($this->_loadedProfile, $name, $module)) {

I just tried with this change, and it seems to work


Posted by Jim Clements (ujim) on 2009-05-22T11:30:05.000+0000

I too was unable to get zf (zend_tool) to create an IndexController because one by the same name existed in application/controllers.

I made the same edit to line 141 in Controllers.php file adding $module as an argument to be passed to hasResource method and was then able to create the file.

Similarly, when trying to create an action in the controller

zf create action index index 1 module

This would give an error because an indexAction already existed in the default IndexController

edited line#129 in Zend/Tool/Project/Provider/Action.php

From: if (self::hasResource($this->_loadedProfile, $name, $controllerName)) To: if (self::hasResource($this->_loadedProfile, $name, $controllerName, $module))

Seems to work okay after that.

Posted by old of Satoru Yoshida ( on 2009-06-19T22:07:02.000+0000

Solved in SVN r16174

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.