diff --git a/php-toolkit/.gitrepo b/php-toolkit/.gitrepo index 088e5e8b..18ba6cf5 100644 --- a/php-toolkit/.gitrepo +++ b/php-toolkit/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = git@github.com:rotdrop/nextcloud-app-toolkit.git branch = main - commit = 98e671c3278ef9839bcf4a0de403b282c27c0106 - parent = cb7707ffe6e64cb88af896bba0e59efb16d2c772 + commit = de7d16207af2905246c67f59935725697ced3f19 + parent = 168fd766b8b528ff80a7db370bf936a8e8d7463f method = merge cmdver = 0.4.5 diff --git a/php-toolkit/README.md b/php-toolkit/README.md index ed91f124..b786c2c0 100644 --- a/php-toolkit/README.md +++ b/php-toolkit/README.md @@ -1,5 +1,16 @@ # nextcloud-app-toolkit + +**Table of Contents** + + - [Description](#description) + - [Setup](#setup) + - [Direct Use as GIT Sub-Repo](#direct-use-as-git-sub-repo) + - [Indirect "Scoped" Use](#indirect-scoped-use) + - [Why](#why) + + + ## Description Some common PHP classes for my Nextcloud apps. The Idea is to use `git @@ -10,6 +21,8 @@ project. ## Setup +### Direct Use as GIT Sub-Repo + Say we choose `lib/Toolkit/` as destination folder, then one could do ``` git subrepo clone THIS_REPOS_URL lib/Toolkit @@ -28,6 +41,30 @@ Then one needs to add an auto-loading directive to the project's `composer.json` This will instruct the `composer` to generate appropriate auto-loading files such that the classes can be found. +### Indirect "Scoped" Use + +When using this toolkit in more than one app then the usual +compatibility problems occur when using the code +[directly](#direct-use-as-git-sub-repo) as described above. Different +apps may depend on different versions but only one shared instance of +the package is used. To work around this it is possible to wrap the +entire package into a namespace. This is done by simple exchanging the +`Rotdrop` PHP namespace by another one. When using `make` for the +build process in an app this can be done with the following `Makefile` +snippet: + +``` makefile +APP_TOOLKIT_DIR = $(ABSSRCDIR)/php-toolkit +APP_TOOLKIT_DEST = $(ABSSRCDIR)/lib/Toolkit +APP_TOOLKIT_NS = CAFEVDB + +include $(APP_TOOLKIT_DIR)/tools/scopeme.mk +``` + +Here `ABSSRCDIR` is assumed to contain the absolute path to the +consuming package and `php-toolkit` is a folder which contains the +sources of this package. + ## Why One could have created a vanilla composer package. However, that has diff --git a/php-toolkit/Traits/UserRootFolderTrait.php b/php-toolkit/Traits/UserRootFolderTrait.php index 82a1778e..c0c466ed 100644 --- a/php-toolkit/Traits/UserRootFolderTrait.php +++ b/php-toolkit/Traits/UserRootFolderTrait.php @@ -111,7 +111,9 @@ public function getUserFolderPath():string * path then it must be relative to the user folder. * * @param null|callable $callback The callback receives two arguments, the - * current file system node and the recursion depth. + * current file system node and the recursion depth. If the current node is + * a folder then the callback is invoked before traversing its directory + * entries. * * @param int $depth Internal recursion depth parameters. The $callback * receives it as second argument. @@ -132,7 +134,9 @@ public function folderWalk(mixed $pathOrFolder, ?callable $callback = null, int } if (!empty($callback)) { - $callback($folder, $depth); + if ($callback($folder, $depth) === false) { + return 0; + } } ++$depth;