Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
Merge branch 'pu/ps/sentry/3605' into '2022.11'
Browse files Browse the repository at this point in the history
tweak(Tinebase/Frontend/Container): remove redundant exception handling

See merge request tine20/tine20!3067
  • Loading branch information
pschuele committed Nov 28, 2022
2 parents efce3d7 + 5da86b9 commit df9e563
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
4 changes: 2 additions & 2 deletions tine20/Tinebase/Container.php
Expand Up @@ -1387,11 +1387,11 @@ public function setContainerColor($_containerId, $_color)
if (! $this->hasGrant(Tinebase_Core::getUser(), $container, Tinebase_Model_Grants::GRANT_ADMIN)) {
throw new Tinebase_Exception_AccessDenied('Permission to set color of container denied.');
}

if (! preg_match('/^#[0-9a-fA-F]{6}$/', $_color)) {
throw new Tinebase_Exception_UnexpectedValue('color is not valid');
}

$container->color = $_color;

return $this->update($container, 'update');
Expand Down
18 changes: 7 additions & 11 deletions tine20/Tinebase/Frontend/Json/Container.php
Expand Up @@ -138,20 +138,16 @@ public function renameContainer($containerId, $newName)

/**
* sets color of a container
*
*
* @param int $containerId
* @param string $color
* @return array updated container
* @throws Tinebase_Exception
* @throws Tinebase_Exception_AccessDenied
*/
public function setContainerColor($containerId, $color)
public function setContainerColor($containerId, $color): array
{
try {
$container = Tinebase_Container::getInstance()->setContainerColor($containerId, $color);
} catch (Tinebase_Exception $e) {
throw new Tinebase_Exception('Container not found or permission to set containername denied!');
}

$container = Tinebase_Container::getInstance()->setContainerColor($containerId, $color);

$result = $container->toArray();
$result['account_grants'] = Tinebase_Container::getInstance()->getGrantsOfAccount(Tinebase_Core::getUser(),
$container)->toArray();
Expand All @@ -165,9 +161,9 @@ public function setContainerColor($containerId, $color)
* @param int $containerId
* @return array
*/
public function getContainerGrants($containerId)
public function getContainerGrants($containerId): array
{
$container = Tinebase_Container::getInstance()->getContainerById($containerId);
Tinebase_Container::getInstance()->getContainerById($containerId);

$result = array(
'results' => array(),
Expand Down

0 comments on commit df9e563

Please sign in to comment.