Files
nextcloud-tables/lib/Controller/TableController.php
Julius Härtl 32e3100e83 feat: Add backend for table archive and favorite flag
Signed-off-by: Julius Härtl <jus@bitgrid.net>
2024-03-01 14:09:49 +01:00

79 lines
1.7 KiB
PHP

<?php
namespace OCA\Tables\Controller;
use OCA\Tables\AppInfo\Application;
use OCA\Tables\Service\TableService;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\DataResponse;
use OCP\IRequest;
use Psr\Log\LoggerInterface;
class TableController extends Controller {
private TableService $service;
private string $userId;
protected LoggerInterface $logger;
use Errors;
public function __construct(
IRequest $request,
LoggerInterface $logger,
TableService $service,
string $userId) {
parent::__construct(Application::APP_ID, $request);
$this->logger = $logger;
$this->service = $service;
$this->userId = $userId;
}
/**
* @NoAdminRequired
*/
public function index(): DataResponse {
return $this->handleError(function () {
return $this->service->findAll($this->userId);
});
}
/**
* @NoAdminRequired
*/
public function show(int $id): DataResponse {
return $this->handleError(function () use ($id) {
return $this->service->find($id);
});
}
/**
* @NoAdminRequired
*/
public function create(string $title, string $template, string $emoji): DataResponse {
return $this->handleError(function () use ($title, $template, $emoji) {
return $this->service->create($title, $template, $emoji);
});
}
/**
* @NoAdminRequired
*/
public function destroy(int $id): DataResponse {
return $this->handleError(function () use ($id) {
return $this->service->delete($id);
});
}
/**
* @NoAdminRequired
*/
public function update(int $id, string $title = null, string $emoji = null, ?bool $archived = null): DataResponse {
return $this->handleError(function () use ($id, $title, $emoji, $archived) {
return $this->service->update($id, $title, $emoji, $archived, $this->userId);
});
}
}