You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to get a singleton instance, that is; I instantiate the Blade Class once (automatically) and then use a static function like Blade::instance() to get the object instantiated already. In this way, I won't have to worry about new Objects being made everytime.
F3 uses the following function to get the desired effect. Can I somehow manage to do the same here?
static function instance() { if (!Registry::exists($class=get_called_class())) { $ref=new Reflectionclass($class); $args=func_get_args(); Registry::set($class, $args?$ref->newinstanceargs($args):new $class); } return Registry::get($class); }
The text was updated successfully, but these errors were encountered:
I want to get a singleton instance, that is; I instantiate the Blade Class once (automatically) and then use a static function like Blade::instance() to get the object instantiated already. In this way, I won't have to worry about new Objects being made everytime.
F3 uses the following function to get the desired effect. Can I somehow manage to do the same here?
static function instance() {
if (!Registry::exists($class=get_called_class())) {
$ref=new Reflectionclass($class);
$args=func_get_args();
Registry::set($class,
$args?$ref->newinstanceargs($args):new $class);
}
return Registry::get($class);
}
The text was updated successfully, but these errors were encountered: