Make Appdata static

* Add fileid for simpleroot folders (only internal)

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2018-05-08 14:42:48 +02:00
parent 95592ff65c
commit 575dc29c27
No known key found for this signature in database
GPG Key ID: F941078878347C0C
3 changed files with 16 additions and 9 deletions

View File

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* @copyright 2016 Roeland Jago Douma <roeland@famdouma.nl>
*
@ -31,6 +32,7 @@ use OC\SystemConfig;
use OCP\Files\Node;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
use OCP\Files\SimpleFS\ISimpleFolder;
class AppData implements IAppData {
@ -55,7 +57,7 @@ class AppData implements IAppData {
*/
public function __construct(IRootFolder $rootFolder,
SystemConfig $systemConfig,
$appId) {
string $appId) {
$this->rootFolder = $rootFolder;
$this->config = $systemConfig;
@ -66,7 +68,7 @@ class AppData implements IAppData {
* @return Folder
* @throws \RuntimeException
*/
private function getAppDataFolder() {
private function getAppDataFolder(): Folder {
if ($this->folder === null) {
$instanceId = $this->config->getValue('instanceid', null);
if ($instanceId === null) {
@ -101,20 +103,20 @@ class AppData implements IAppData {
return $this->folder;
}
public function getFolder($name) {
public function getFolder(string $name): ISimpleFolder {
$node = $this->getAppDataFolder()->get($name);
/** @var Folder $node */
return new SimpleFolder($node);
}
public function newFolder($name) {
public function newFolder(string $name): ISimpleFolder {
$folder = $this->getAppDataFolder()->newFolder($name);
return new SimpleFolder($folder);
}
public function getDirectoryListing() {
public function getDirectoryListing(): array {
$listing = $this->getAppDataFolder()->getDirectoryListing();
$fileListing = array_map(function(Node $folder) {
@ -128,4 +130,8 @@ class AppData implements IAppData {
return array_values($fileListing);
}
public function getId(): int {
return $this->getAppDataFolder()->getId();
}
}

View File

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* @copyright 2016 Roeland Jago Douma <roeland@famdouma.nl>
*
@ -44,7 +45,7 @@ class Factory {
* @param string $appId
* @return AppData
*/
public function get($appId) {
public function get(string $appId): AppData {
return new AppData($this->rootFolder, $this->config, $appId);
}
}

View File

@ -42,7 +42,7 @@ interface ISimpleRoot {
* @throws \RuntimeException
* @since 11.0.0
*/
public function getFolder($name);
public function getFolder(string $name): ISimpleFolder;
/**
* Get all the Folders
@ -52,7 +52,7 @@ interface ISimpleRoot {
* @throws \RuntimeException
* @since 11.0.0
*/
public function getDirectoryListing();
public function getDirectoryListing(): array;
/**
* Create a new folder named $name
@ -63,5 +63,5 @@ interface ISimpleRoot {
* @throws \RuntimeException
* @since 11.0.0
*/
public function newFolder($name);
public function newFolder(string $name): ISimpleFolder;
}