/** * Creates a new, trivial instance of Elgg\Application and set it as the singleton instance. * If the singleton is already set, it's returned. * * @return self */ private static function create() { if (self::$_instance === null) { self::$_instance = new self(new Di\ServiceProvider(new Config())); } return self::$_instance; }
/** * Flag this application as running for testing (PHPUnit) * * @param bool $testing Is testing application * @return void */ public static function setTestingApplication($testing = true) { self::$testing_app = $testing; }
/** * Load all Elgg procedural code and wire up boot events, but don't boot * * This is used for internal testing purposes * * @return void * @access private * @internal */ public function loadCore() { if (function_exists('elgg')) { return; } $lib_dir = $this->engine_dir . "/lib"; // we only depend on it to be defining _elgg_services function require_once "{$lib_dir}/autoloader.php"; // set up autoloading and DIC _elgg_services($this->services); // load the rest of the library files from engine/lib/ // All on separate lines to make diffs easy to read + make it apparent how much // we're actually loading on every page (Hint: it's too much). $lib_files = array('elgglib.php', 'access.php', 'actions.php', 'admin.php', 'annotations.php', 'cache.php', 'comments.php', 'configuration.php', 'cron.php', 'database.php', 'entities.php', 'extender.php', 'filestore.php', 'friends.php', 'group.php', 'input.php', 'languages.php', 'mb_wrapper.php', 'memcache.php', 'metadata.php', 'metastrings.php', 'navigation.php', 'notification.php', 'objects.php', 'output.php', 'pagehandler.php', 'pageowner.php', 'pam.php', 'plugins.php', 'private_settings.php', 'relationships.php', 'river.php', 'sessions.php', 'sites.php', 'statistics.php', 'system_log.php', 'tags.php', 'user_settings.php', 'users.php', 'upgrade.php', 'views.php', 'widgets.php', 'deprecated-1.9.php', 'deprecated-1.10.php', 'deprecated-1.11.php', 'deprecated-1.12.php'); // isolate global scope call_user_func(function () use($lib_dir, $lib_files) { $setups = array(); // include library files, capturing setup functions foreach ($lib_files as $file) { $setup = (require_once "{$lib_dir}/{$file}"); if ($setup instanceof \Closure) { $setups[$file] = $setup; } } // store instance to be returned by elgg() self::$_instance = $this; $events = $this->services->events; $hooks = $this->services->hooks; // run setups foreach ($setups as $func) { $func($events, $hooks); } }); }
/** * Creates a new, trivial instance of Elgg\Application and set it as the singleton instance. * If the singleton is already set, it's returned. * * @return self */ private static function create() { if (self::$_instance === null) { // we need to register for shutdown before Symfony registers the // session_write_close() function. https://github.com/Elgg/Elgg/issues/9243 register_shutdown_function(function () { // There are cases where we may exit before this function is defined if (function_exists('_elgg_shutdown_hook')) { _elgg_shutdown_hook(); } }); self::$_instance = new self(new Di\ServiceProvider(new Config())); } return self::$_instance; }