magento为什么不自动加载父类 [英] Why doesn't magento autoload parent class

查看:53
本文介绍了magento为什么不自动加载父类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个模块,可以通过

I have a module which will use my controller over magento's by doing

<routers>
  <checkout>
    <args>
      <modules>
        <Some_Thing before="Mage_Checkout">Some_Thing</Some_Thing>
      </modules>
    </args>
  </checkout>
</routers>

在扩展核心类的类中,我必须明确要求该类.有人知道为什么吗?

In my class that extends the core class I have to explicitly require the class. Does anyone know why this is?

推荐答案

Magento自动加载器是一种简单的用下划线替换下划线"算法.由于Zend Framework对控制器的命名不同,并且由于Magento使用Zend的某些部分,并且受Zend的启发,因此其控制器使用Zend约定命名,并放置在controllers文件夹中,这意味着标准自动加载例程将无法正常工作.

The Magento autoloader is a simple "replace underscores with slashes" algorithm. Because Zend Framework names its controllers differently, and because Magento uses parts of Zend and is inspired by Zend in others, its controllers are named with Zend conventions and placed in a controllers folder, meaning the standard autoload routine won't work.

最终,在Magento的路由过程中会自动包含控制器类,但PHP不会自动加载程序.取而代之的是使用自定义的PHP代码来处理此问题.

It ends up controller classes are automatically included during Magento's routing process but NOT by the PHP auto loader. Instead, there's custom PHP code to handle this.

因此,在路由过程中,由于您已告知Magento使用控制器而不是Magento的控制器来处理特定请求,因此它是唯一包含在内的控制器.

So, during routing, because you've told Magento to use your controllers instead of Magento's controller for a particular request, it's the only controller that gets included.

最好的猜测是对控制器重写的请求使原始开发人员措手不及,尽管他们很乐意通过路由选择一种解决方案,但重构控制器自动加载代码并不是优先考虑的事情.

Best guess is the request for controller overrides caught the original developers off guard, and while they've been happy to jury rig a solution with routing, it hasn't been a priority to refactor the controller autoload code.

这篇关于magento为什么不自动加载父类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆