Closed eko3alpha closed 9 years ago
on the aliases register, you should alias the facade class instead the underlying class
try this and see if it works
$app->container->singleton('system_alert', function () {
return new SystemAlert();
});
class SystemAlertFacade extends SlimFacades\Facade
{
// return the name of the component from the DI container
protected static function getFacadeAccessor() { return 'system_alert'; }
}
$config['aliases'] = array(
'Alert' => 'SystemAlertFacade',
);
SlimFacades\Facade::registerAliases($config['aliases']);
Thank you! That worked perfectly!
I must be doing something wrong when attempting to create a custom facade. I have a SystemAlert class I'd like to create a Facade for and I have this.
From my understanding this is all you need to do and I should be able to use the SystemAlerts class like so:
Unfortunately it doesn't work. However all the following work:
$this->app->system_alert->set(); // inside a controller using DI $alert = new SystemAlert(); $alert = App:make('system_alert');
In my SystemAlert class I have several properties. If I instantiate the SystemAlerts class I can call the methods and they can access the properties without issues. However when I attempt to use the facade I get errors stating that my properties do not exist. I'm at a loss as to what I'm doing wrong.
Thanks!