Name for strings defining Magento class names

Magento uses a factory template to create objects from classes

$model = Mage::getModel('catalog/product'); //Mage_Catalog_Model_Product by default $helper = Mage::helper('catalog/data'); //Mage_Catalog_Helper_Data by default 

These strings are expanded into class names, and the system can be configured to replace the default values.

What or should these lines call? I abused the term URI (sometimes ordered the abuse of the phrase "URI-like"), but this is not entirely true. The "class name" does not seem to be correct either, as this can easily cause confusion (are you talking about the name of the factory class or the name of the real PHP class?)

Anyone have any bumps on this?

+4
source share
6 answers

This line is called a class (model, block, helper - depends on the context of use). Alias โ€‹โ€‹naming rule: group / entity.

Each module can define its own group or define overwrites for an existing one.

+8
source

Great question Alan. I would be interested to know that other frameworks that use the Factory template and its "shortcut" call it.

I think you are on the right track with the "Identifier" part of the URI. I would think that "Class Identifier" or "Model Identifier" works. The class identifier is a bit more general and allows you to use a helper script.

+3
source

I usually use the class handle , as it does not come with luggage, like the "class path", and they seem to be "handles" of some kind.

+3
source

Frankly, there is no official name for this internal label in a particular class.

But I know that the first part before the slash is called the โ€œclass groupโ€, this is not the name of the module, because Magento can share different classes from different modules in the same group (using the rewrite statement). Yes, there is an initial module that defines the default class prefix, but you can change this prefix by merging configuration files.

The second part, which I would like to call the name of the model / model resource / block / helper.

In general, one could name:

  • model path for Mage::getModel() and Mage::getSingleton()
  • block path for Mage::getBlockSingleton() and $layout->createBlock()
  • helper path for Mage::helper()

But there is no official name for this design. So itโ€™s not a rule to call this way :)


UPDATE : In Mage_Core_Model_Config::getGroupedClassName() this construct is called Class Id, so perhaps this name is more clear.

+3
source

I would say "class path", but this can confuse those who worked in languages, where it has more formal meaning and implementation in the language / interpreter / compiler.

+2
source

In my head, I used the term "class request". You can go one step further and make it "CRI" - similar to a URI, but not "Universal". However, now I think about it, getModel and createBlock do not return classes, they return instances ...

+2
source

All Articles