mirror of
https://github.com/nerzhul/ocsms.git
synced 2025-06-07 16:06:15 +00:00
Create a basic SmsController
This commit is contained in:
parent
8d03780e6f
commit
3ad96daa21
@ -14,7 +14,7 @@ namespace OCA\OcSms\AppInfo;
|
||||
|
||||
use \OCP\AppFramework\App;
|
||||
|
||||
use \OCA\OcSms\Controller\PageController;
|
||||
use \OCA\OcSms\Controller\SmsController;
|
||||
|
||||
|
||||
class Application extends App {
|
||||
@ -28,8 +28,9 @@ class Application extends App {
|
||||
/**
|
||||
* Controllers
|
||||
*/
|
||||
$container->registerService('PageController', function($c) {
|
||||
return new PageController(
|
||||
|
||||
$container->registerService('SmsController', function($c) {
|
||||
return new SmsController(
|
||||
$c->query('AppName'),
|
||||
$c->query('Request'),
|
||||
$c->query('UserId')
|
||||
@ -45,6 +46,4 @@ class Application extends App {
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -22,6 +22,5 @@ namespace OCA\OcSms\AppInfo;
|
||||
$application = new Application();
|
||||
|
||||
$application->registerRoutes($this, array('routes' => array(
|
||||
array('name' => 'page#index', 'url' => '/', 'verb' => 'GET'),
|
||||
array('name' => 'page#do_echo', 'url' => '/echo', 'verb' => 'POST'),
|
||||
array('name' => 'sms#push', 'url' => '/push', 'verb' => 'POST'),
|
||||
)));
|
||||
|
@ -1,54 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* ownCloud - ocsms
|
||||
*
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later. See the COPYING file.
|
||||
*
|
||||
* @author Loic Blot <loic.blot@unix-experience.fr>
|
||||
* @copyright Loic Blot 2014
|
||||
*/
|
||||
|
||||
namespace OCA\OcSms\Controller;
|
||||
|
||||
|
||||
use \OCP\IRequest;
|
||||
use \OCP\AppFramework\Http\TemplateResponse;
|
||||
use \OCP\AppFramework\Controller;
|
||||
|
||||
class PageController extends Controller {
|
||||
|
||||
private $userId;
|
||||
|
||||
public function __construct($appName, IRequest $request, $userId){
|
||||
parent::__construct($appName, $request);
|
||||
$this->userId = $userId;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* CAUTION: the @Stuff turn off security checks, for this page no admin is
|
||||
* required and no CSRF check. If you don't know what CSRF is, read
|
||||
* it up in the docs or you might create a security hole. This is
|
||||
* basically the only required method to add this exemption, don't
|
||||
* add it to any other method if you don't exactly know what it does
|
||||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function index() {
|
||||
$params = array('user' => $this->userId);
|
||||
return new TemplateResponse('ocsms', 'main', $params); // templates/main.php
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Simply method that posts back the payload of the request
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function doEcho($echo) {
|
||||
return array('echo' => $echo);
|
||||
}
|
||||
|
||||
|
||||
}
|
33
controller/smscontroller.php
Normal file
33
controller/smscontroller.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* ownCloud - ocsms
|
||||
*
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later. See the COPYING file.
|
||||
*
|
||||
* @author Loic Blot <loic.blot@unix-experience.fr>
|
||||
* @copyright Loic Blot 2014
|
||||
*/
|
||||
|
||||
namespace OCA\OcSms\Controller;
|
||||
|
||||
|
||||
use \OCP\IRequest;
|
||||
use \OCP\AppFramework\Http\TemplateResponse;
|
||||
use \OCP\AppFramework\Controller;
|
||||
|
||||
class SmsController extends Controller {
|
||||
|
||||
private $userId;
|
||||
|
||||
public function __construct($appName, IRequest $request, $userId){
|
||||
parent::__construct($appName, $request);
|
||||
$this->userId = $userId;
|
||||
}
|
||||
|
||||
public function push() {
|
||||
return array("test" => "test2");
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user