Zend Framework

"zf create action" cannot properly handle hyphenated action names

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.8.4
  • Fix Version/s: 1.10.0
  • Component/s: Zend_Tool
  • Labels:
    None

Description

Currently, the zf command (which utilizes Zend_Tool_Project) cannot handle action names with hyphens:

%> zf create project myproject myproject
%> cd myproject
%> zf create controller mycontroller
%> zf create action my-hyphenated-action mycontroller
%> cat application/controllers/MycontrollerController.php

...
public function my-hyphenated-actionAction()
{
...
}
...

For the time being, to get around this issue (while working with the default router), remove the hyphens and capitalize the first letter of section of the action name after the first:

zf create action my-hyphenated-action mycontroller

becomes:

zf create action myHyphenatedAction mycontroller

Activity

Hide
Enrico Faifer added a comment -

If I digit

zf create action myHyphenatedAction mycontroller

then I have a problem with view :

myproject/application/views/scripts/mycontroller/myHyphenatedAction.phtml

Show
Enrico Faifer added a comment - If I digit zf create action myHyphenatedAction mycontroller then I have a problem with view : myproject/application/views/scripts/mycontroller/myHyphenatedAction.phtml
Hide
Ralph Schindler added a comment -

Changed to "Bug" since it produces unworking code.
Marked as "Major" and for "Next mini release"

Show
Ralph Schindler added a comment - Changed to "Bug" since it produces unworking code. Marked as "Major" and for "Next mini release"
Hide
Mark Smith added a comment -

There is also a problem when the controller is created with a hyphen.
eg.
zf create controller about-us
Creating a controller at /home/sites/application/controllers/About-usController.php
Creating an index action method in controller about-us
Creating a view script for the index action method at /home/sites/application/views/scripts/about-us/index.phtml
Creating a controller test file at /home/sites/tests/application/controllers/About-usControllerTest.php
Updating project profile '/home/sites/.zfproject.xml'

The contents of About-usController.php is:
<?php
class AboutUsController extends Zend_Controller_Action {
public function init() { /* Initialize action controller here */ }

public function indexAction() { // action body }
}

The class name is what I'd expect but because the file name includes the hyphen the autoloader cannot find the file and therefore trying to access /about-us fails to load.

Show
Mark Smith added a comment - There is also a problem when the controller is created with a hyphen. eg. zf create controller about-us Creating a controller at /home/sites/application/controllers/About-usController.php Creating an index action method in controller about-us Creating a view script for the index action method at /home/sites/application/views/scripts/about-us/index.phtml Creating a controller test file at /home/sites/tests/application/controllers/About-usControllerTest.php Updating project profile '/home/sites/.zfproject.xml' The contents of About-usController.php is: <?php class AboutUsController extends Zend_Controller_Action { public function init() { /* Initialize action controller here */ } public function indexAction() { // action body } } The class name is what I'd expect but because the file name includes the hyphen the autoloader cannot find the file and therefore trying to access /about-us fails to load.
Hide
Ralph Schindler added a comment -

Fixed in r18631 in incubator. Will be included in 1.10 release

Show
Ralph Schindler added a comment - Fixed in r18631 in incubator. Will be included in 1.10 release

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: