简体   繁体   中英

What's the best pratice to use tools function with Zend Framework

I'm currently on a Zend project, i create a controller named company , where i created many action. Now i want to code some utils function, they will be only used in one action of my controller let's say nameAction .

Here is what i did :

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


    }

}

This code works well, but out some function into a funvtion is a little weird no?

Where should i put these tools functions get_inner_html & check_if_social_account , in the CompanyController as private functions? In a separate files ?

If this functions will be used in other class, extract it to another class. If not create private methods in your controller class.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM