Created feeds and UI for feeds and newsletter
🚀 Deploy website on push / 🎉 Deploy (push) Successful in 19s
🚀 Deploy website on push / 🎉 Deploy (push) Successful in 19s
Signed-off-by: rodude123 <rodude123@gmail.com>
This commit is contained in:
Vendored
+1
-1
@@ -17,7 +17,7 @@ class projectData
|
||||
{
|
||||
/**
|
||||
* Get all project data
|
||||
* @return array - Array of all project data or error message
|
||||
* @return array<array> - Array of all project data or error message
|
||||
*/
|
||||
public function getProjectData(): array
|
||||
{
|
||||
|
||||
Vendored
+62
-62
@@ -50,78 +50,78 @@ class projectRoutes implements routesInterface
|
||||
$app->patch("/projectData/{id}", function (Request $request, Response $response, array $args)
|
||||
{
|
||||
$data = $request->getParsedBody();
|
||||
if ($args["id"] != null)
|
||||
if ($args["id"] == null)
|
||||
{
|
||||
if (empty($data["title"]) || empty($data["isMainProject"]) || empty($data["information"]) || empty($data["gitLink"]))
|
||||
{
|
||||
// uh oh sent some empty data
|
||||
$response->getBody()->write(json_encode(array("error" => "Only some of the data was sent")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
$isMainProject = $data["isMainProject"] === "true";
|
||||
$update = $this->projectData->updateProjectData($args["id"], $data["title"], $isMainProject, $data["information"], $data["projectLink"], $data["gitLink"]);
|
||||
|
||||
if ($update === "project not found")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Project with ID " . $args["id"] . " not found")));
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
|
||||
if ($update === "unset main project")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Can't unset project as main project, try updating another project as the main project")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
if (!$update)
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Something went wrong")));
|
||||
return $response->withStatus(500);
|
||||
}
|
||||
|
||||
return $response;
|
||||
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
|
||||
return $response->withStatus(400);
|
||||
if (empty($data["title"]) || empty($data["isMainProject"]) || empty($data["information"]) || empty($data["gitLink"]))
|
||||
{
|
||||
// uh oh sent some empty data
|
||||
$response->getBody()->write(json_encode(array("error" => "Only some of the data was sent")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
$isMainProject = $data["isMainProject"] === "true";
|
||||
$update = $this->projectData->updateProjectData($args["id"], $data["title"], $isMainProject, $data["information"], $data["projectLink"], $data["gitLink"]);
|
||||
|
||||
if ($update === "project not found")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Project with ID " . $args["id"] . " not found")));
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
|
||||
if ($update === "unset main project")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Can't unset project as main project, try updating another project as the main project")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
if (!$update)
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Something went wrong")));
|
||||
return $response->withStatus(500);
|
||||
}
|
||||
|
||||
return $response;
|
||||
});
|
||||
|
||||
$app->delete("/projectData/{id}", function (Request $request, Response $response, array $args)
|
||||
{
|
||||
if ($args["id"] != null)
|
||||
if ($args["id"] == null)
|
||||
{
|
||||
$message = $this->projectData->deleteProjectData($args["id"]);
|
||||
|
||||
if ($message === "project not found")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Project with ID " . $args["id"] . " not found")));
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
|
||||
if ($message === "cannot delete")
|
||||
{
|
||||
//uh oh cannot delete the main project
|
||||
$response->getBody()->write(json_encode(array("error" => "Cannot delete the main project")));
|
||||
return $response->withStatus(409);
|
||||
}
|
||||
|
||||
if ($message === "error")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Something went wrong")));
|
||||
return $response->withStatus(500);
|
||||
}
|
||||
|
||||
return $response;
|
||||
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
$response->getBody()->write(json_encode(array("error" => "Please provide an ID")));
|
||||
return $response->withStatus(400);
|
||||
$message = $this->projectData->deleteProjectData($args["id"]);
|
||||
|
||||
if ($message === "project not found")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Project with ID " . $args["id"] . " not found")));
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
|
||||
if ($message === "cannot delete")
|
||||
{
|
||||
//uh oh cannot delete the main project
|
||||
$response->getBody()->write(json_encode(array("error" => "Cannot delete the main project")));
|
||||
return $response->withStatus(409);
|
||||
}
|
||||
|
||||
if ($message === "error")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Something went wrong")));
|
||||
return $response->withStatus(500);
|
||||
}
|
||||
|
||||
return $response;
|
||||
});
|
||||
|
||||
$app->post("/projectData", function (Request $request, Response $response)
|
||||
|
||||
Reference in New Issue
Block a user