使用Zend Framework工具的最佳实践是什么?

时间:2013-07-12 07:34:18

标签: php oop zend-framework

我目前正在使用Zend项目,我创建了一个名为company的控制器,我在其中创建了许多操作。 现在我想编写一些utils函数,它们只会在我的控制器的一个动作中使用,比方说nameAction

这就是我所做的:

class CompanyController extends Zend_Controller_Action {

    public function nameAction( $name = null ) {

        function get_inner_html( $node ) {
            // Some code goes here
            return $html;
        }

        function check_if_social_account($url) {
          // Some code goes here
            return $social_account;
        }

     // Here is the main code of my controller


    }

}

这段代码运行良好,但将某些功能转化为功能有点奇怪没有?

我应该在哪里使用这些工具get_inner_html& check_if_social_accountCompanyController中的私有函数?在一个单独的文件中?

1 个答案:

答案 0 :(得分:1)

如果此函数将在其他类中使用,则将其提取到另一个类。如果没有在控制器类中创建私有方法。