| @@ 35-57 (lines=23) @@ | ||
| 32 | * @param string $project Project database name, URL, or domain name. |
|
| 33 | * @return View |
|
| 34 | */ |
|
| 35 | public function normalizeProject($project) |
|
| 36 | { |
|
| 37 | $proj = ProjectRepository::getProject($project, $this->container); |
|
| 38 | ||
| 39 | if (!$proj->exists()) { |
|
| 40 | return new View( |
|
| 41 | [ |
|
| 42 | 'error' => "$project is not a valid project", |
|
| 43 | ], |
|
| 44 | Response::HTTP_NOT_FOUND |
|
| 45 | ); |
|
| 46 | } |
|
| 47 | ||
| 48 | return new View( |
|
| 49 | [ |
|
| 50 | 'domain' => $proj->getDomain(), |
|
| 51 | 'url' => $proj->getUrl(), |
|
| 52 | 'api' => $proj->getApiUrl(), |
|
| 53 | 'database' => $proj->getDatabaseName(), |
|
| 54 | ], |
|
| 55 | Response::HTTP_OK |
|
| 56 | ); |
|
| 57 | } |
|
| 58 | ||
| 59 | /** |
|
| 60 | * Get all namespaces of the given project. This endpoint also does the same thing |
|
| @@ 66-89 (lines=24) @@ | ||
| 63 | * @param string $project The project name. |
|
| 64 | * @return View |
|
| 65 | */ |
|
| 66 | public function namespaces($project) |
|
| 67 | { |
|
| 68 | $proj = ProjectRepository::getProject($project, $this->container); |
|
| 69 | ||
| 70 | if (!$proj->exists()) { |
|
| 71 | return new View( |
|
| 72 | [ |
|
| 73 | 'error' => "$project is not a valid project", |
|
| 74 | ], |
|
| 75 | Response::HTTP_NOT_FOUND |
|
| 76 | ); |
|
| 77 | } |
|
| 78 | ||
| 79 | return new View( |
|
| 80 | [ |
|
| 81 | 'domain' => $proj->getDomain(), |
|
| 82 | 'url' => $proj->getUrl(), |
|
| 83 | 'api' => $proj->getApiUrl(), |
|
| 84 | 'database' => $proj->getDatabaseName(), |
|
| 85 | 'namespaces' => $proj->getNamespaces(), |
|
| 86 | ], |
|
| 87 | Response::HTTP_OK |
|
| 88 | ); |
|
| 89 | } |
|
| 90 | ||
| 91 | /** |
|
| 92 | * Count the number of automated edits the given user has made. |
|