Skip to content

Commit

Permalink
Use array_map to cast values to int, remove castings.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukemacausland committed Aug 20, 2024
1 parent 1519885 commit a5ad694
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Controller/Admin/DataObject/DataObjectHelperController.php
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ protected function updateGridConfigFavourites(?GridConfig $gridConfig, array $me
$sharedUserIds = $metadata['sharedUserIds'];

if ($sharedUserIds) {
$sharedUsers = explode(',', $sharedUserIds);
$sharedUsers = array_map('intval', explode(',', $sharedUserIds));
}
}

Expand All @@ -991,7 +991,7 @@ protected function updateGridConfigFavourites(?GridConfig $gridConfig, array $me
foreach ($sharedUsers as $id) {
$global = true;
$favourite = GridConfigFavourite::getByOwnerAndClassAndObjectId(
(int) $id,
$id,
$gridConfig->getClassId(),
$objectId,
$gridConfig->getSearchType()
Expand All @@ -1008,15 +1008,15 @@ protected function updateGridConfigFavourites(?GridConfig $gridConfig, array $me
}

// Check if the user is the owner. If that is the case we do not update the favourite
if ((int) $favouriteGridConfig->getOwnerId() === (int) $id) {
if ((int) $favouriteGridConfig->getOwnerId() === $id) {
continue;
}
}
}

// Check if the user has already a global favourite then we do not save the favourite as global
$favourite = GridConfigFavourite::getByOwnerAndClassAndObjectId(
(int) $id,
$id,
$gridConfig->getClassId(),
0,
$gridConfig->getSearchType()
Expand All @@ -1032,7 +1032,7 @@ protected function updateGridConfigFavourites(?GridConfig $gridConfig, array $me
}

// Check if the user is the owner. If that is the case we do not update the global favourite
if ($favouriteGridConfig->getOwnerId() === (int) $id) {
if ($favouriteGridConfig->getOwnerId() === $id) {
$global = false;
}
}
Expand All @@ -1042,7 +1042,7 @@ protected function updateGridConfigFavourites(?GridConfig $gridConfig, array $me
$favourite->setGridConfigId($gridConfig->getId());
$favourite->setClassId($gridConfig->getClassId());
$favourite->setObjectId($objectId);
$favourite->setOwnerId((int) $id);
$favourite->setOwnerId($id);
$favourite->setType($gridConfig->getType());
$favourite->setSearchType($gridConfig->getSearchType());
$favourite->save();
Expand Down

0 comments on commit a5ad694

Please sign in to comment.