nextcloud-app-radio/controller/stationcontroller.php

75 lines
1.6 KiB
PHP
Raw Normal View History

2017-01-08 08:37:11 +00:00
<?php
2017-02-21 16:57:30 +00:00
namespace OCA\Radio\Controller;
2017-01-08 08:37:11 +00:00
use OCP\IRequest;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Controller;
2017-02-21 16:57:30 +00:00
use OCA\Radio\Service\StationService;
2017-01-08 08:37:11 +00:00
2017-02-21 16:57:30 +00:00
class StationController extends Controller {
2017-01-08 08:37:11 +00:00
private $service;
private $userId;
use Errors;
public function __construct($AppName, IRequest $request,
2017-02-21 16:57:30 +00:00
StationService $service, $UserId){
2017-01-08 08:37:11 +00:00
parent::__construct($AppName, $request);
$this->service = $service;
$this->userId = $UserId;
}
/**
* @NoAdminRequired
*/
2017-02-21 16:57:30 +00:00
public function index() {
2017-01-08 08:37:11 +00:00
return new DataResponse($this->service->findAll($this->userId));
}
/**
* @NoAdminRequired
*
2017-02-21 16:57:30 +00:00
* @param int $id
*/
public function show($id) {
return $this->handleNotFound(function () use ($id) {
return $this->service->find($id, $this->userId);
});
}
/**
* @NoAdminRequired
*
* @param string $stationid
2017-01-08 08:37:11 +00:00
*/
2017-02-21 16:57:30 +00:00
public function create($stationid) {
return $this->service->create($stationid, $this->userId);
}
/**
* @NoAdminRequired
*
* @param int $id
* @param string $stationid
*/
public function update($id, $stationid) {
return $this->handleNotFound(function () use ($id, $stationid) {
return $this->service->update($id, $stationid, $this->userId);
});
2017-01-08 08:37:11 +00:00
}
/**
* @NoAdminRequired
*
* @param int $id
*/
2017-02-21 16:57:30 +00:00
public function destroy($id) {
2017-01-08 08:37:11 +00:00
return $this->handleNotFound(function () use ($id) {
return $this->service->delete($id, $this->userId);
});
}
}