Skip to content

Latest commit

 

History

History
41 lines (28 loc) · 1.29 KB

extension-registry.md

File metadata and controls

41 lines (28 loc) · 1.29 KB

Extension registry

Custom registry set

Maybe you need a custom registry for your plugin.

Put this code into a file that is loaded by a plugin, or autoloaded:

<?php
namespace Kirby\Registry;

class Type extends Entry {
	protected static $entries = [];

	public function set($name, $path) {
		static::$entries[$name] = $path;
	}
	public function get($name = null) {
		return static::$entries[$name];
	}
}

Change Type to the name of your registry type name, but make sure the first letter is uppercase. Also you are allowed to change $entries to a name of your choice.

To set and get the registry do this:

$kirby->set('type', 'name', __DIR__ . '/types/name.php');
echo $kirby->get('type', 'name');

Change type to the name of your registry type name, but make sure everything is lowercase. Also change name to the name of your registry entry.

Sources