Skip to content

Commit

Permalink
remove unused parts, fix psalm
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Borysenko <[email protected]>
  • Loading branch information
andrey18106 committed Jul 30, 2024
1 parent 2eb3249 commit 3bcc649
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 36 deletions.
22 changes: 2 additions & 20 deletions lib/Db/ExAppMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ public function findByAppId(string $appId): Entity {
);
$apps = $this->buildExAppRoutes($qb->executeQuery()->fetchAll());
if (count($apps) === 0) {
throw new DoesNotExistException();
throw new DoesNotExistException('No ExApp found with appId ' . $appId);
}
if (count($apps) > 1) {
throw new MultipleObjectsReturnedException();
throw new MultipleObjectsReturnedException('Multiple ExApps found with appId ' . $appId);
}
return $apps[0];
}
Expand Down Expand Up @@ -208,24 +208,6 @@ public function registerExAppRoutes(ExApp $exApp, array $routes): int {
return $count;
}

/**
* @throws Exception
*/
public function updateExAppRoutes(ExApp $exApp, array $routes): int {
$count = 0;
foreach ($routes as $route) {
$qb = $this->db->getQueryBuilder();
$qb->update('ex_apps_routes')
->set('url', $qb->createNamedParameter($route['url']))
->set('verb', $qb->createNamedParameter($route['verb']))
->set('access_level', $qb->createNamedParameter($route['access_level']))
->set('headers_to_exclude', $qb->createNamedParameter($route['headers_to_exclude']))
->where($qb->expr()->eq('appid', $qb->createNamedParameter($exApp->getAppid())));
$count += $qb->executeStatement();
}
return $count;
}

/**
* @throws Exception
*/
Expand Down
19 changes: 3 additions & 16 deletions lib/Service/ExAppService.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ public function unregisterExApp(string $appId): bool {
if ($r !== 1) {
$this->logger->error(sprintf('Error while unregistering %s ExApp from the database.', $appId));
}
$r = $this->removeExAppRoutes($exApp);
if ($r === null) {
$rmRoutes = $this->removeExAppRoutes($exApp);
if ($rmRoutes === null) {
$this->logger->error(sprintf('Error while unregistering %s ExApp routes from the database.', $appId));
}
$this->cache->remove('/ex_apps');
return $r === 1;
return $r === 1 && $rmRoutes !== null;
}

public function getExAppFreePort(): int {
Expand Down Expand Up @@ -383,17 +383,4 @@ public function removeExAppRoutes(ExApp $exApp): ?ExApp {
return null;
}
}

public function updateExAppRoutes(ExApp $exApp, array $routes): ?ExApp {
try {
if ($this->exAppMapper->updateExAppRoutes($exApp, $routes) === count($routes)) {
$exApp->setRoutes($routes);
$this->resetCaches();
return $exApp;
}
} catch (Exception) {
return null;
}
return null;
}
}
8 changes: 8 additions & 0 deletions tests/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,21 @@
</file>
<file src="lib/Controller/ExAppProxyController.php">
<UndefinedClass>
<code><![CDATA[$options['headers']]]></code>
<code><![CDATA[$options['headers']]]></code>
<code><![CDATA[CookieJar]]></code>
<code><![CDATA[CookieJar]]></code>
<code><![CDATA[RequestOptions]]></code>
<code><![CDATA[RequestOptions]]></code>
<code><![CDATA[RequestOptions]]></code>
<code><![CDATA[RequestOptions]]></code>
<code><![CDATA[RequestOptions]]></code>
<code><![CDATA[RequestOptions]]></code>
<code><![CDATA[RequestOptions]]></code>
<code><![CDATA[RequestOptions]]></code>
<code><![CDATA[RequestOptions]]></code>
<code><![CDATA[RequestOptions]]></code>
<code><![CDATA[RequestOptions]]></code>
<code><![CDATA[SetCookie]]></code>
</UndefinedClass>
</file>
Expand Down

0 comments on commit 3bcc649

Please sign in to comment.