Skip to content

Commit

Permalink
git subrepo pull php-toolkit
Browse files Browse the repository at this point in the history
subrepo:
  subdir:   "php-toolkit"
  merged:   "de7d162"
upstream:
  origin:   "[email protected]:rotdrop/nextcloud-app-toolkit.git"
  branch:   "main"
  commit:   "de7d162"
git-subrepo:
  version:  "0.4.5"
  origin:   "???"
  commit:   "???"
  • Loading branch information
rotdrop committed Mar 24, 2023
1 parent 168fd76 commit 5679653
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
4 changes: 2 additions & 2 deletions php-toolkit/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[subrepo]
remote = [email protected]:rotdrop/nextcloud-app-toolkit.git
branch = main
commit = 98e671c3278ef9839bcf4a0de403b282c27c0106
parent = cb7707ffe6e64cb88af896bba0e59efb16d2c772
commit = de7d16207af2905246c67f59935725697ced3f19
parent = 168fd766b8b528ff80a7db370bf936a8e8d7463f
method = merge
cmdver = 0.4.5
37 changes: 37 additions & 0 deletions php-toolkit/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# nextcloud-app-toolkit

<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc -->
**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)

<!-- markdown-toc end -->

## Description

Some common PHP classes for my Nextcloud apps. The Idea is to use `git
Expand All @@ -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
Expand All @@ -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
Expand Down
8 changes: 6 additions & 2 deletions php-toolkit/Traits/UserRootFolderTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;

Expand Down

0 comments on commit 5679653

Please sign in to comment.