Mit Hilfe von David oben Antwort würde Hope David nichts dagegen haben.
Ich versuche es genauer zu erklären
Beginnen Sie mit Mage.php und gehen Sie zum Funktionshelfer
public static function helper($name)
{
$registryKey = '_helper/' . $name;
if (!self::registry($registryKey)) {
$helperClass = self::getConfig()->getHelperClassName($name);
self::register($registryKey, new $helperClass);
}
return self::registry($registryKey);
}
ein) $registryKey = '_helper/' . $name;
Ergebnis: $registryKey = _helper/sales
b) check now registry key exits ot not,if not then set a registry
variabel
if (!self::registry($registryKey)) {
es wird true when system is first times
für eine Sitzung:
c) $helperClass = self::getConfig()->getHelperClassName($name);
das heißt
$ name = sales send an Mage_Core_Model_Config Klassenfunktion getHelperClassName zum Abrufen des Hilfeklassen-Sendeparameters
d) Dann setze Klasse name is registry variable
e
self::register($registryKey, new $helperClass);
Ergebnis: may be proper class name Mage_Sales_Helper_Data
Geht jetzt zur Funktion getHelperClassName der Klasse Mage_Core_Model_Config
a) Diese Funktion Ruft die Hilfsklassen-Namenszeichenfolge $ name ab
public function getHelperClassName($helperName)
{
if (strpos($helperName, '/') === false) {
$helperName .= '/data';
}
return $this->getGroupedClassName('helper', $helperName);
}
Funktion erklären:
$helperName is sales
die Logik:
if (strpos($helperName, '/') === false) {
wird true as $helperName=sales then set $helperName=sales/data
b) return $this->getGroupedClassName('helper', $helperName);
Einzelheiten:
call function getGroupedClassName with params 'helper','sales/data'
and getGroupedClassName return class name of helper class
Jetzt gehe zur Funktion getGroupedClassName('helper','sales/data',null)
public function getGroupedClassName($groupType, $classId, $groupRootNode=null)
{
if (empty($groupRootNode)) {
$groupRootNode = 'global/'.$groupType.'s';
}
$classArr = explode('/', trim($classId));
$group = $classArr[0];
$class = !empty($classArr[1]) ? $classArr[1] : null;
if (isset($this->_classNameCache[$groupRootNode][$group][$class])) {
return $this->_classNameCache[$groupRootNode][$group][$class];
}
$config = $this->_xml->global->{$groupType.'s'}->{$group};
// First - check maybe the entity class was rewritten
$className = null;
if (isset($config->rewrite->$class)) {
$className = (string)$config->rewrite->$class;
} else {
/**
* Backwards compatibility for pre-MMDB extensions.
* In MMDB release resource nodes <..._mysql4> were renamed to <..._resource>. So <deprecatedNode> is left
* to keep name of previously used nodes, that still may be used by non-updated extensions.
*/
if ($config->deprecatedNode) {
$deprecatedNode = $config->deprecatedNode;
$configOld = $this->_xml->global->{$groupType.'s'}->$deprecatedNode;
if (isset($configOld->rewrite->$class)) {
$className = (string) $configOld->rewrite->$class;
}
}
}
// Second - if entity is not rewritten then use class prefix to form class name
if (empty($className)) {
if (!empty($config)) {
$className = $config->getClassName();
}
if (empty($className)) {
$className = 'mage_'.$group.'_'.$groupType;
}
if (!empty($class)) {
$className .= '_'.$class;
}
$className = uc_words($className);
}
$this->_classNameCache[$groupRootNode][$group][$class] = $className;
return $className;
}
** diese Funktionsaufgabe **
retrieve class name by class group
param string $groupType currently supported helper
param string $classId slash separated class identifier, ex. group/class
param string $groupRootNode optional config path for group config
return string
ein)$classArr = explode('/', trim($classId));
Ergebnis:explode helper name(sales/data by /) for getting classs name in array $classArr
b)$class = !empty($classArr[1]) ? $classArr[1] : null;
Ergebnis:as $classArr[1] is data then value of $class is data
c) $config = $this->_xml->global->{$groupType.'s'}->{$group};
Einzelheiten:get config setting then $config = $this->_xml->global->helpers->sales;
d)$className = null;
Details :set $className null
.
e) check rewrite class exits in config.xml files, check if class is rewrite then
you can easly get
Code: if (isset ($ config-> rewrite -> $ class)) {Ergebnis:if (isset($config->rewrite->data)) {
f)for default magento ,it false to goto else
überspringen if ($ config-> deprecatedNode) {
as deprecatedNode is for model($grouptype) and ,it only used for _mysql4
G) if (empty($className)) {
Ergebnis:
if sales helper not rewrite then if (empty($className)) { becomes true
h)if (!empty($config)) {
Ergebnis
:false
if (!empty($config)) { becomes false;`
i) if (empty($className)) {
Ergebnis:as $className is till
null then this code is true
j) Klassenergebnis machen $className = 'mage_'.$group.'_'.$groupType;
:
$group=sales
$groupTyp=helper
$className = 'mage_sales_helper';
k)
if (!empty($class)) {
$className .= '_'.$class;
}
Ergebnis:
as $class = data the this condition is true and $className = 'mage_sales_helper_data';
l) ** in Großbuchstaben machen $className = uc_words($className)
; Jetzt return class return $ className; Das ist Mage_Sales_Helper_Data **
Dank an
David Manners und Rajeev K Tomy