Migrate major controllers to appframework
parent
128b8454cc
commit
595b2fbf96
@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ownCloud - Documents App
|
||||
*
|
||||
* @author Victor Dubiniuk
|
||||
* @copyright 2013 Victor Dubiniuk victor.dubiniuk@gmail.com
|
||||
*
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
*/
|
||||
|
||||
namespace OCA\Documents;
|
||||
|
||||
class Controller {
|
||||
|
||||
/**
|
||||
* Do security precheck
|
||||
* @param bool callcheck - whether security token check is needed
|
||||
* @return string userId of the currently logged in user
|
||||
*/
|
||||
public static function preDispatch($callcheck = true){
|
||||
if ($callcheck){
|
||||
\OCP\JSON::callCheck();
|
||||
}
|
||||
\OCP\JSON::checkAppEnabled('documents');
|
||||
\OCP\JSON::checkLoggedIn();
|
||||
return \OCP\User::getUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Do security precheck for not logged in users
|
||||
* @param bool callcheck - whether security token check is needed
|
||||
*/
|
||||
public static function preDispatchGuest($callcheck = true){
|
||||
if ($callcheck){
|
||||
\OCP\JSON::callCheck();
|
||||
}
|
||||
\OCP\JSON::checkAppEnabled('documents');
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* ownCloud - Documents App
|
||||
*
|
||||
* @author Victor Dubiniuk
|
||||
* @copyright 2014 Victor Dubiniuk victor.dubiniuk@gmail.com
|
||||
*
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
*/
|
||||
|
||||
namespace OCA\Documents\AppInfo;
|
||||
|
||||
use \OCP\AppFramework\App;
|
||||
|
||||
use \OCA\Documents\Controller\UserController;
|
||||
use \OCA\Documents\Controller\SessionController;
|
||||
use \OCA\Documents\Controller\DocumentController;
|
||||
|
||||
class Application extends App {
|
||||
public function __construct (array $urlParams = array()) {
|
||||
parent::__construct('documents', $urlParams);
|
||||
|
||||
$container = $this->getContainer();
|
||||
|
||||
/**
|
||||
* Controllers
|
||||
*/
|
||||
$container->registerService('UserController', function($c) {
|
||||
return new UserController(
|
||||
$c->query('AppName'),
|
||||
$c->query('Request')
|
||||
);
|
||||
});
|
||||
$container->registerService('SessionController', function($c) {
|
||||
return new SessionController(
|
||||
$c->query('AppName'),
|
||||
$c->query('Request'),
|
||||
$c->query('UserId')
|
||||
);
|
||||
});
|
||||
$container->registerService('DocumentController', function($c) {
|
||||
return new DocumentController(
|
||||
$c->query('AppName'),
|
||||
$c->query('Request'),
|
||||
$c->query('CoreConfig'),
|
||||
$c->query('L10N'),
|
||||
$c->query('UserId')
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* Core
|
||||
*/
|
||||
|
||||
$container->registerService('CoreConfig', function($c) {
|
||||
return $c->query('ServerContainer')->getConfig();
|
||||
});
|
||||
$container->registerService('L10N', function($c) {
|
||||
return $c->query('ServerContainer')->getL10N($c->query('AppName'));
|
||||
});
|
||||
$container->registerService('UserId', function() {
|
||||
return \OCP\User::getUser();
|
||||
});
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue