Testing how to develop an app

This commit is contained in:
root
2022-03-14 20:05:46 +00:00
parent 1984e55837
commit a30a4f13ec
11 changed files with 99 additions and 38 deletions

View File

@ -28,4 +28,11 @@ class PageController extends Controller {
return new TemplateResponse('mywiki', 'index'); // templates/index.php
}
/**
* @NoAdminRequired
*/
public function test() {
return new DataResponse('JDG::Test');
}
}

View File

@ -23,9 +23,15 @@
/**
* @NoAdminRequired
*/
public function index() {
return new DataResponse($this->service->test($this->userId));
public function test() {
$x = $this->service->test($this->userId);
return new DataResponse(print_r($x,true));
}
/**
* @NoAdminRequired
*/
public function index() {
return new DataResponse($this->service->findAll($this->userId));
}

View File

@ -1,32 +1,25 @@
<?php
namespace OCA\MyWiki\Helper;
use OCP\AppFramework\Files\Folder;
use OCP\Files\IRootFolder;
class WikiHelper {
public static function isFolder(int $folderId) :bool {
$mount = \OC\Files\Filesystem::getMountsForFileId($folderId);
/*
isReadable()
getById($folderId)
isCreatable()
isUpdateable()
lock()
$config = new \OC\Config('config/');
$base_path = $config->getValue('datadirectory')
datadirectory is the key in the array defined in config.php that contains the base directory.
$basepath now contains a path like /var/www/html/nextcloud/data.
*/
// ToDo
$nodes = \OC\Files\Node\Folder::getById($folderId);
return true;
public static function isFolder(IRootFolder $storage, int $folderId) :bool {
$nodes = $storage->getById($folderId);
if ( count($nodes)>0 ) {
return $nodes[0]->getType() == \OCP\Files\Node::TYPE_FOLDER;
}
return false;
}
public static function isWiki(int $folderId) :bool {
return \OC\Files\Filesystem::nodeExists('.wiki');
public static function isWiki(IRootFolder $storage, int $folderId) :string {
$nodes = $storage->getById($folderId);
if ( count($nodes)>0 ) {
$nodeStorage = $nodes[0]->getStorage();
return $nodeStorage->file_get_contents('/wiki.yaml');
// getPath()
// getStorage()
}
return false;
}
public static function initWiki(int $folderId, string $title) :bool {
// ToDo

View File

@ -1,13 +1,13 @@
<?php
namespace OCA\NotesTutorial\Migration;
namespace OCA\MyWiki\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\SimpleMigrationStep;
use OCP\Migration\IOutput;
class Version1400Date20181013124731 extends SimpleMigrationStep {
class Version000000Date20220302210900 extends SimpleMigrationStep {
/**
* @param IOutput $output

View File

@ -10,20 +10,28 @@ use OCA\MyWiki\Db\Wiki;
use OCA\MyWiki\Db\WikiMapper;
use OCA\MyWiki\Helper\WikiHelper;
use \OCP\Files\Storage;
use \OCP\Files\IRootFolder;
use \OCP\IUserSession;
class WikiService {
private $mapper;
private $rootFolder;
private $storage;
private $userSession;
public function __construct(WikiMapper $mapper,IRootFolder $rootFolder){
public function __construct(WikiMapper $mapper, IRootFolder $storage) {
// , IUserSession $userSession ) {
$this->mapper = $mapper;
$this->rootFolder = $rootFolder;
// $this->userSession = $userSession;
$this->storage = $storage;
// , IUserSession $userSession
}
public function test(string $userId) {
echo 'JDG :: Test for '.$userId;
return WikiHelper::isWiki($this->storage, 208);
}
public function findAll(string $userId) {