How can I create an own registry set of files or folder?

For example the Modules plugin by @lukasbestle are creating an own registry set. How is that done? I could not figure it out. A simple example without distractions would be awesome.

This is what I might have as a starting point:

$kirby->set('my_custom_set', 'my_set_name', $my_set_path);

Update

Maybe something like this:

class MyCustomClass extends Entry {
  public function set($name, $path) {
  }
  public function get($name = null) {
  }
}

I’ll try more tomorrow…

You only need a class in the Kirby\Registry namespace. This class needs to be loaded or registered in an autoloader. This is the Module registry.

I had the same problem before I looked at the registry code and realized what @lukasbestle said. I found it a bit weird, so I ended up “projecting” my registry into the Kirby\registry namespace by extending my actual registry implementation as seen in the Constructs plugin.

@lukasbestle @lord-executor

Added to the unofficial docs

Thanks! Now we have an inofficial documentation about it: https://github.com/jenstornell/kirby-secrets/wiki/Extension-registry

Added to Bricks plugin

I’ve also added this great feature to Bricks: https://github.com/jenstornell/kirby-bricks/blob/master/docs/registry.md

I need it myself when I’m building Bricks UI, to get access to Bricks snippet controllers.

1 Like

That’s of course possible but not necessary. :slight_smile: