Skip to content

Commit

Permalink
Update CMSEditLinkAPI.php
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnysideup authored Jul 8, 2020
1 parent 90f4982 commit beb13ed
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/Api/CMSEditLinkAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ public static function find_edit_link_for_object($objectOrClassName, $action = n
if ($modelAdminURLOverwrite) {
$classFound = true;
} else {
$modelNameToEdit = self::getModelAdmin($modelNameToEdit);
if($modelNameToEdit) {
$modelAdminResults = self::getModelAdmin($modelNameToEdit);
if(count($modelAdminResults)) {
$modelNameToEdit = $modelAdminResults['ModelNameToEdit'];
$myModelAdminclassObject = $modelAdminResults['MyModelAdminclassObject'];
$classFound = true;
}
}
Expand Down Expand Up @@ -100,7 +102,7 @@ protected static function getModelAdmin($modelNameToEdit) : string
{
$originalModelNameToEdit = $modelNameToEdit;
if(! isset(self::$_cache[$originalModelNameToEdit])) {
self::$_cache[$originalModelNameToEdit] = '';
self::$_cache[$originalModelNameToEdit] = [];
$classFound = false;
foreach (ClassInfo::subclassesFor(ModelAdmin::class) as $i => $myAdminClassName) {
for ($includeChildren = 0; $includeChildren < 2; $includeChildren++) {
Expand Down Expand Up @@ -140,7 +142,10 @@ protected static function getModelAdmin($modelNameToEdit) : string
}
}
if($classFound) {
self::$_cache[$originalModelNameToEdit] = $modelNameToEdit;
self::$_cache[$originalModelNameToEdit] = [
'ModelNameToEdit' => $modelNameToEdit,
'MyModelAdminclassObject' => $myModelAdminclassObject,
];
}
return self::$_cache[$originalModelNameToEdit];
}
Expand Down

0 comments on commit beb13ed

Please sign in to comment.