77 lines
1.6 KiB
PHP
77 lines
1.6 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace OCA\Agency\Controller;
|
|
|
|
use OCP\IRequest;
|
|
use OCP\AppFramework\Http\DataResponse;
|
|
use OCP\AppFramework\Controller;
|
|
|
|
use OCA\Agency\Service\AgencyService;
|
|
|
|
class AgencyController extends Controller {
|
|
|
|
private $service;
|
|
private $Id;
|
|
|
|
use Errors;
|
|
|
|
public function __construct(string $AppName, IRequest $request,
|
|
AgencyService $service){
|
|
parent::__construct($AppName, $request);
|
|
$this->service = $service;
|
|
}
|
|
|
|
/**
|
|
* @NoAdminRequired
|
|
*/
|
|
public function index() {
|
|
return new DataResponse($this->service->findAll($this->Id));
|
|
}
|
|
|
|
/**
|
|
* @NoAdminRequired
|
|
*
|
|
* @param int $id
|
|
*/
|
|
public function show(int $id) {
|
|
return $this->handleNotFound(function () use ($id) {
|
|
return $this->service->find($id);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* @NoAdminRequired
|
|
* @NoCSRFRequired
|
|
*
|
|
* @param string $title
|
|
* @param string $content
|
|
*/
|
|
public function create(string $name) {
|
|
return $this->service->create($name);
|
|
}
|
|
|
|
/**
|
|
* @NoAdminRequired
|
|
*
|
|
* @param int $id
|
|
* @param string $title
|
|
*/
|
|
public function update(int $id, string $name) {
|
|
return $this->handleNotFound(function () use ($id, $name) {
|
|
return $this->service->update($id, $name);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* @NoAdminRequired
|
|
*
|
|
* @param int $id
|
|
*/
|
|
public function destroy(int $id) {
|
|
return $this->handleNotFound(function () use ($id) {
|
|
return $this->service->delete($id);
|
|
});
|
|
}
|
|
|
|
} |