3

I find many functions used in Bootstrap class in Zend Framework applications like:

_initRoute()
_initLocale()
_initLayout()
.......

but i searched for it's reference but I fond nothing

Zend_Application_Bootstrap_BootstrapAbstract
Zend_Application_Bootstrap_Bootstrap

none of them contains any of these functions.

Where can i find the full reference of that functions?

Siguza
  • 21,155
  • 6
  • 52
  • 89
ahmedsafan86
  • 1,776
  • 1
  • 26
  • 49

2 Answers2

6

Basically, these are resource plugins located in library/Zend/Application/Resource/. You may create also your custom ones.

See My detailed answer to very similar question which should fit also to this one.

Also, see BootstrapAbstract.php:

/**
 * Get class resources (as resource/method pairs)
 *
 * Uses get_class_methods() by default, reflection on prior to 5.2.6,
 * as a bug prevents the usage of get_class_methods() there.
 *
 * @return array
 */
public function getClassResources()
{
    if (null === $this->_classResources) {
        if (version_compare(PHP_VERSION, '5.2.6') === -1) {
            $class        = new ReflectionObject($this);
            $classMethods = $class->getMethods();
            $methodNames  = array();

            foreach ($classMethods as $method) {
                $methodNames[] = $method->getName();
            }
        } else {
            $methodNames = get_class_methods($this);
        }

        $this->_classResources = array();
        foreach ($methodNames as $method) {
            if (5 < strlen($method) && '_init' === substr($method, 0, 5)) {
                $this->_classResources[strtolower(substr($method, 5))] = $method;
            }
        }
    }

    return $this->_classResources;
}
Community
  • 1
  • 1
takeshin
  • 49,108
  • 32
  • 120
  • 164
  • Indeed the correct answer explained well in the other question! – David Snabel-Caunt Feb 22 '11 at 00:06
  • 1
    firstly thank you. well but where can i find all standard resources? for example i need to customize the database adapter, i need to customize layouts .. do i have to search Google every time i need such information? or there are standard methods or resources to be used?? – ahmedsafan86 Feb 22 '11 at 08:21
  • @Ahmed I have updated the answer: The resources are located in library/Zend/Application/Resource/ – takeshin Feb 22 '11 at 10:05
3

These function aren't defined anywhere, just in Bootstrap.php - these are called resource methods. At the bootstraping process, ZF automatically calls each function defined in Bootstrap.php which starts with _init.

Read more here: http://framework.zend.com/manual/en/zend.application.theory-of-operation.html

Radek Benkel
  • 8,278
  • 3
  • 32
  • 41