Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions lib/Horde/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,15 @@ public static function createVariable(
) {
$arr = explode(':', $type, 2);
if (count($arr) == 2) {
$app = $arr[0];
$app = ucfirst($arr[0]);
$name = $arr[1];
} else {
$app = 'Horde';
$name = $arr[0];
}

$class = $app . '\\Form\\V3\\' . ucfirst($name) . 'Variable';
$name = ucfirst($name);
$class = $app . '\\Form\\V3\\' . $name . 'Variable';
$modern = class_exists($class);
if ($modern) {
$var = new $class(
Expand All @@ -221,11 +222,12 @@ public static function createVariable(
);
} elseif (self::$legacy) {
$class = $app . '_Form_Type_' . $name;
if (!class_exists($class)) {
throw new Horde_Exception(sprintf('Nonexistent class "%s" for field type "%s"', $class, $name));
}
$var = new $class();
$var = class_exists($class) ? new $class() : null;
} else {
$var = null;
}

if ($var === null) {
throw new Horde_Exception(sprintf('Nonexistent class "%s" for field type "%s"', $class, $name));
}

Expand Down
9 changes: 8 additions & 1 deletion src/V3/BaseVariable.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,14 @@ public function getType()
*/
public function getTypeName(): string
{
return mb_strtolower(str_replace('Horde\Form\V3\\', '', substr($this::class, 0, -8)));
$parts = explode('\\', $this::class);
$app = strtolower($parts[0]);
$name = strtolower(substr($parts[count($parts) - 1], 0, -8));
if ($app !== 'horde') {
// legacy
$name = $app . '_form_type_' . $name;
}
return $name;
}

/**
Expand Down
Loading