зеркало из https://github.com/nextcloud/news.git
prototype of business layer for api
This commit is contained in:
Родитель
d6e8bd9cf2
Коммит
165540d346
|
@ -46,6 +46,10 @@ namespace OCA\News;
|
|||
\OC::$CLASSPATH['OCA\News\NewsController'] = 'apps/news/controller/news.controller.php';
|
||||
\OC::$CLASSPATH['OCA\News\NewsAjaxController'] = 'apps/news/controller/news.ajax.controller.php';
|
||||
|
||||
\OC::$CLASSPATH['OCA\News\FolderBL'] = 'apps/news/folder.bl.php';
|
||||
|
||||
\OC::$CLASSPATH['OCA\News\API_Folder'] = 'apps/news/external_api/folder.php';
|
||||
|
||||
|
||||
/**
|
||||
* @return a new DI container with prefilled values for the news app
|
||||
|
@ -106,5 +110,12 @@ function createDIContainer(){
|
|||
$c['FolderMapper'], $c['ItemMapper']);
|
||||
};
|
||||
|
||||
/**
|
||||
* BUSINESS LAYER OBJECTS
|
||||
*/
|
||||
$newsContainer['FolderBL'] = function($c){
|
||||
return new FolderBL($c['FolderMapper']);
|
||||
};
|
||||
|
||||
return $newsContainer;
|
||||
}
|
|
@ -200,3 +200,15 @@ $this->create('news_ajax_importOPML', '/import')->action(
|
|||
callAjaxController('NewsAjaxController', 'uploadOPML', $params);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* External API for folders
|
||||
*/
|
||||
\OCP\API::register(
|
||||
'get',
|
||||
'/news/folders',
|
||||
array('OCA\News\API_Folder ', 'getAll'),
|
||||
'news',
|
||||
\OC_API::USER_AUTH
|
||||
);
|
||||
|
|
|
@ -53,6 +53,15 @@ class FolderMapper {
|
|||
|
||||
return $folderlist;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the forest (list of trees) of folders children of $parentid
|
||||
* @param
|
||||
* @returns
|
||||
*/
|
||||
public function getAll() {
|
||||
return self::childrenOf(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the forest (list of trees) of folders children of $parentid,
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
namespace OCA\News;
|
||||
|
||||
use \OCA\News\Controller\FolderController;
|
||||
|
||||
class API_Folder {
|
||||
|
||||
public static function getAll() {
|
||||
$container = createDIContainer();
|
||||
$controller = $container['FolderBL'];
|
||||
return \OC_OCS_Result($controller->getAll());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace OCA\News;
|
||||
|
||||
class FolderBL {
|
||||
|
||||
public function __construct($folderMapper){
|
||||
$this->folderMapper = $folderMapper;
|
||||
}
|
||||
|
||||
public static function getAll() {
|
||||
$folders = $this->folderMapper->getAll();
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче