getNamespaceName()."\\", path: dirname($refl->getFileName())."/" ); spl_autoload_register(function ($class) use ($psr4) { if (str_starts_with($class, $psr4->namespace)) { $part = substr($class, strlen($psr4->namespace)); $file = $psr4->path . strtr($part, "\\", DIRECTORY_SEPARATOR).".php"; if (file_exists($file)) { require_once $file; } } }); SparkApplication::$instance->getPluginManager()->registerPlugin($name, $plugin); } function get_plugin(string $name) { return SparkApplication::$instance->getPluginManager()->getPlugin($name); } function register_command(Command $command) { SparkApplication::$instance->add($command); } function get_environment(): Environment { return SparkApplication::$instance->getEnvironment(); } function register_resource_type(string $name, string $type) { SparkApplication::$instance->getResourceManager()->registerResourceType($name, $type); } function create_resource(string $name, string $type, ...$options) { return SparkApplication::$instance->getResourceManager()->createNamedResource($name, $type, $options); } function get_resource(string $name) { return SparkApplication::$instance->getResourceManager()->getNamedResource($name); } function resource(string $name) { return get_resource($name); } function read_config($file=null) { if (!$file) return; $abs = get_environment()->getConfigDirectory() . "/" . $file; if (!file_exists($abs)) { //fprintf(STDERR, "warning: Can't read config file %s\n", $abs); return []; } return (array)json_decode(file_get_contents($abs), true); } // ------ Filters ------ $FILTERS = []; function register_filter(string $name, callable $filter) { global $FILTERS; $FILTERS[$name] = $filter; } function get_registered_filters(): array { global $FILTERS; return array_keys($FILTERS); } function get_filter(string $name): ?callable { global $FILTERS; return $FILTERS[$name]??null; }