Core::registerAutoloader()

Register psr4 autoloader manually

Description

Source

File: bp-integrations/learndash/core/Core.php

	public function registerAutoloader()
	{
		spl_autoload_register(function($class) {
			$psr4 = [
				'Buddyboss\LearndashIntegration\Core'       => 'core',
				'Buddyboss\LearndashIntegration\Library'    => 'library',
				'Buddyboss\LearndashIntegration\Buddypress' => 'buddypress',
				'Buddyboss\LearndashIntegration\Buddypress\Generators' => 'buddypress/generators',
				'Buddyboss\LearndashIntegration\Buddypress\Components' => 'buddypress/components',
				'Buddyboss\LearndashIntegration\Learndash'  => 'learndash',
			];

			$segments  = explode('\\', $class);
			$className = array_pop($segments);
			$namespace = implode('\\', $segments);

		    if (array_key_exists($namespace, $psr4)) {
		    	require_once $this->path("/{$psr4[$namespace]}/{$className}.php");
		    }
		});
	}

Changelog

Changelog
Version Description
BuddyBoss 1.0.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.