Magento使用工厂模式来实例化类中的对象
$model = Mage::getModel('catalog/product'); //Mage_Catalog_Model_Product by default $helper = Mage::helper('catalog/data'); //Mage_Catalog_Helper_Data by default这些字符串被扩展为类名,系统可以被配置为替换默认值。
什么是或应该调用这些字符串? 我一直在滥用术语URI(有时用“类似URI”这个短语来缓和这种滥用),但这并不正确。 “Class Name”看起来不正确,因为它很容易引起混淆(你是在谈论工厂类名称还是实际的PHP类名称?)
任何人都有权对此进行任何刺杀?
Magento uses a factory pattern for instantiating objects from classes
$model = Mage::getModel('catalog/product'); //Mage_Catalog_Model_Product by default $helper = Mage::helper('catalog/data'); //Mage_Catalog_Helper_Data by defaultThese strings are expanded into classnames, and the System can be configured to replace the default values.
What are, or should, these strings be called? I've been abusing the term URI (sometimes tempering the abuse with the phrase "URI-like"), but that's not really right. "Class Name" doesn't seem right either, as it could easily cause confusion (Are you talking about the factory class name, or the actual PHP class name?)
Anyone have any stabs at authority on this?
最满意答案
这个字符串被称为类(模型,块,助手 - 依赖于使用上下文)别名。 别名命名规则是: 组/实体 。
每个模块可以定义自己的组或为现有组定义重写。
This string is called class (model, block, helper - depends from usage context) alias. Alias naming rule is: group/entity.
Each module can define own group or define rewrites for existing one.
更多推荐
发布评论