<?php namespace nur\v\bs3; use nur\str; use nur\v\bs3\fo\Form; use nur\v\bs3\fo\FormManager; class fox { const MANAGER_CLASS = FormManager::class; protected static $manager_class; /** * spécifier la classe à utiliser pour instancier le gestionnaire de * formulaires * * cette méthode *doit* être appelée avant d'appeler la méthode * {@link manager()} */ static final function set_manager_class(string $manager_class) { self::$manager_class = $manager_class; } /** @var FormManager */ protected static $manager; static final function set_manager(FormManager $manager) { self::$manager = $manager; } /** obtenir l'instance globale de gestionnaire de formulaire */ static final function manager(): FormManager { if (self::$manager === null) { $manager_class = self::$manager_class; if ($manager_class === null) $manager_class = static::MANAGER_CLASS; self::$manager = new $manager_class(); } return self::$manager; } static final function __callStatic($name, $args) { $name = str::us2camel($name); return call_user_func_array([self::manager(), $name], $args); } ############################################################################# static function get(?string $type=null, ?array $params=null): Form { return self::manager()->get($type, $params); } }