Please help me understand Concrete CMS facades

I know that this is generally deprecated… but it’s still there all over the place in concrete core code, and I’m having a hard time connecting the dots.

So just to take a very concrete (hah!) example, I found the following line in …/src/User/RegistrationService.php:

            $type = $this->application->make('manager/notification/types')->driver('user_signup');

I’ve tried to figure out what $this->application->make('manager/notification/types') returns, i.e. what files defines the class of the instance it returns. Unfortunately, I haven’t been able to find it. Reading up on Laravel hasn’t helped much, unfortunately.

I have an ulterior motif, of course. I plan to put together code for an invitation function, integrated into the core code if possible, or as a package… but I don’t feel like I have enough of an understanding of the registration process to be able to do a good enough job.

Please help?

Cheers,
Richard

$this->application (usually it’s $this->app or $app) is a Service container created during application startup.

Service container is an object that allows you to easily load different classes (they are all called Services).
Instead full class path, you can often use short abbrs like
$app->make('manager/notification/types')

If you don’t have access to Service container, you can always call application facade:

$app = \Concrete\Core\Support\Facade\Application::getFacadeApplication();

Go to concrete/config/app.php and you will find list of all Service providers (these are classes that group similar Services).

Look for line:

'core_notification' => '\Concrete\Core\Notification\NotificationServiceProvider',

Now, go to NotificationServiceProvider class and you will find that it registers multiple things among:

$this->app->singleton(
	'manager/notification/types',
	function ($app) {
		return $app->make('Concrete\Core\Notification\Type\Manager');
	}
);

And that’s you class.

Thank you! app->singleton was the missing bit that connects the dots for me.

Cheers,
Richard