new type API

This commit is contained in:
Roland Gruber 2017-04-25 20:03:38 +02:00
parent b4248bc898
commit cd4cc1ae26
6 changed files with 36 additions and 54 deletions

View file

@ -69,28 +69,6 @@ function getTypes() {
return $return;
}
/**
* Returns the alias name of an account type.
*
* @param string $type type name
* @param \LAMConfig $config config (optional, uses $_SESSION['config'] by default)
* @return string type alias
*/
function getTypeAlias($type, $config = null) {
if (($config == null) && !empty($_SESSION['config'])) {
$config = $_SESSION['config'];
}
if ($config != null) {
$typeSettings = $config->get_typeSettings();
if (!empty($typeSettings['customLabel_' . $type])) {
return $typeSettings['customLabel_' . $type];
}
}
$scope = getScopeFromTypeId($type);
$obj = new $scope();
return $obj->getAlias();
}
/**
* Returns the description of an account type.
*
@ -98,21 +76,10 @@ function getTypeAlias($type, $config = null) {
* @return string type description
*/
function getTypeDescription($type) {
$obj = new $type();
$obj = new $type(null);
return $obj->getDescription();
}
/**
* Returns the class name for the list object.
*
* @param string $type account type
* @return string class name
*/
function getListClassName($type) {
$obj = new $type();
return $obj->getListClassName();
}
/**
* Returns the default attribute list for an account type.
* It is used as default value for the configuration editor.
@ -255,8 +222,11 @@ class ConfiguredType {
if ($this->alias !== null) {
return $this->alias;
}
$this->alias = getTypeAlias($this->id, $this->typeManager->getConfig());
return $this->alias;
$typeSettings = $this->typeManager->getConfig()->get_typeSettings();
if (!empty($typeSettings['customLabel_' . $this->id])) {
return $typeSettings['customLabel_' . $this->id];
}
return $this->getBaseType()->getAlias();
}
/**