From beb13ede199e3da2c8b82673f54c2a1e4ab51567 Mon Sep 17 00:00:00 2001 From: Nicolaas Date: Wed, 8 Jul 2020 23:47:37 +1200 Subject: [PATCH] Update CMSEditLinkAPI.php --- src/Api/CMSEditLinkAPI.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Api/CMSEditLinkAPI.php b/src/Api/CMSEditLinkAPI.php index 898dab7..3eab2cd 100644 --- a/src/Api/CMSEditLinkAPI.php +++ b/src/Api/CMSEditLinkAPI.php @@ -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; } } @@ -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++) { @@ -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]; }