【问题标题】:Zend Framework Bootstrap functions from where to getZend Framework Bootstrap 函数从哪里得到
【发布时间】:2011-02-21 19:28:17
【问题描述】:

我发现 Zend Framework 应用程序的 Bootstrap 类中使用了许多函数 喜欢:

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

但我搜索了它的参考,但我什么都不喜欢

Zend_Application_Bootstrap_BootstrapAbstract
Zend_Application_Bootstrap_Bootstrap

它们都不包含任何这些功能。

我在哪里可以找到这些函数的完整参考资料?

【问题讨论】:

    标签: zend-framework bootstrapping


    【解决方案1】:

    基本上,这些是位于library/Zend/Application/Resource/ 中的resource plugins。您也可以创建自定义的。

    参见My detailed answervery similar question,这也应该适合这个。

    另外,请参阅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;
    }
    

    【讨论】:

    • 确实正确答案在另一个问题中解释得很好!
    • 首先谢谢你。好吧,但是我在哪里可以找到所有标准资源?例如我需要自定义数据库适配器,我需要自定义布局.. 每次我需要这些信息时我都必须搜索谷歌吗?还是有标准的方法或资源可以使用??
    • @Ahmed 我已经更新了答案:资源位于 library/Zend/Application/Resource/
    【解决方案2】:

    这些函数没有在任何地方定义,只是在Bootstrap.php - 这些被称为资源方法。在引导过程中,ZF 会自动调用以_init 开头的Bootstrap.php 中定义的每个函数。

    在此处阅读更多信息:http://framework.zend.com/manual/en/zend.application.theory-of-operation.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多