mirror of
https://github.com/projectsend/projectsend.git
synced 2026-09-16 08:35:07 +00:00
6e47d76ba6
Client file sharing, rebuilt from the ground up: a private area per client, resumable uploads, folders, groups and categories, sharing with expiry dates and download limits, comments, file versions, an activity log, a REST API, and sixteen languages. This repository begins here. ProjectSend 2 was developed privately, and that development history is not published — the previous generation remains available, with its own history, at projectsend/legacy. Free software under the GNU General Public License v2, or (at your option) any later version.
53 lines
1.3 KiB
PHP
53 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Modules\Api;
|
|
|
|
use Illuminate\Routing\Route;
|
|
use Illuminate\Support\Facades\Route as Router;
|
|
|
|
/**
|
|
* Which module endpoints this install actually exposes, for GET /api/v1/me.
|
|
*
|
|
* Derived from the registered routes rather than remembered from the
|
|
* RegisteringApiModules dispatch, because that dispatch does not happen on
|
|
* a route-cached install: `route:cache` loads routes from the cache file
|
|
* and never executes routes/api.php. Route *names* survive caching, so
|
|
* reading them back is the one source that is correct in both cases.
|
|
*/
|
|
class ApiModuleRegistry
|
|
{
|
|
/** @var list<string>|null */
|
|
private ?array $slugs = null;
|
|
|
|
/**
|
|
* @return list<string>
|
|
*/
|
|
public function slugs(): array
|
|
{
|
|
if ($this->slugs !== null) {
|
|
return $this->slugs;
|
|
}
|
|
|
|
$slugs = [];
|
|
|
|
foreach (Router::getRoutes()->getRoutes() as $route) {
|
|
/** @var Route $route */
|
|
$name = $route->getName();
|
|
|
|
if ($name === null || ! str_starts_with($name, 'api.modules.')) {
|
|
continue;
|
|
}
|
|
|
|
$slug = explode('.', substr($name, strlen('api.modules.')))[0];
|
|
|
|
if ($slug !== '') {
|
|
$slugs[$slug] = true;
|
|
}
|
|
}
|
|
|
|
return $this->slugs = array_keys($slugs);
|
|
}
|
|
}
|