public getNamespacePrefix ( string $section = 'auto' ) : string | ||
$section | string | The section you want to get information for |
return | string | The namespace prefix for the component's classes, e.g. \Foobar\Example\Site\ |
public function getNamespacePrefix($section = 'auto')
{
// Get the namespaces for the front-end and back-end parts of the component
$frontEndNamespace = '\\' . $this->componentNamespace . '\\Site\\';
$backEndNamespace = '\\' . $this->componentNamespace . '\\Admin\\';
// Special case: if the frontend and backend paths are identical, we don't use the Site and Admin namespace
// suffixes after $this->componentNamespace (so you may use FOF with JApplicationWeb apps)
if ($this->frontEndPath == $this->backEndPath) {
$frontEndNamespace = '\\' . $this->componentNamespace . '\\';
$backEndNamespace = '\\' . $this->componentNamespace . '\\';
}
switch ($section) {
default:
case 'auto':
if ($this->platform->isBackend()) {
return $backEndNamespace;
} else {
return $frontEndNamespace;
}
break;
case 'inverse':
if ($this->platform->isBackend()) {
return $frontEndNamespace;
} else {
return $backEndNamespace;
}
break;
case 'site':
return $frontEndNamespace;
break;
case 'admin':
return $backEndNamespace;
break;
}
}
/** * Load a helper file * * @param string $helperClass The last part of the name of the helper * class. * * @return void * * @deprecated 3.0 Just use the class in your code. That's what the autoloader is for. */ public function loadHelper($helperClass = null) { // Get the helper class name $className = '\\' . $this->container->getNamespacePrefix() . 'Helper\\' . ucfirst($helperClass); // This trick autoloads the helper class. We can't instantiate it as // helpers are (supposed to be) abstract classes with static method // interfaces. class_exists($className); }