Elgg\Application::loadCore PHP Method

loadCore() public method

This is used for internal testing purposes
public loadCore ( ) : void
return void
    public function loadCore()
    {
        if (function_exists('elgg')) {
            return;
        }
        $lib_dir = self::elggDir()->chroot("engine/lib");
        // 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('autoloader.php', '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', '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-2.1.php', 'deprecated-3.0.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->getPath($file));
                if ($setup instanceof \Closure) {
                    $setups[$file] = $setup;
                }
            }
            // store instance to be returned by elgg()
            self::$_instance = $this;
            // set up autoloading and DIC
            _elgg_services($this->services);
            $events = $this->services->events;
            $hooks = $this->services->hooks;
            // run setups
            foreach ($setups as $func) {
                $func($events, $hooks);
            }
        });
    }

Usage Example

Example #1
0
 /**
  * Bootstraps test suite
  *
  * @global stdClass $CONFIG Global config
  * @global stdClass $_ELGG  Global vars
  * @return void
  */
 public static function bootstrap()
 {
     date_default_timezone_set('America/Los_Angeles');
     error_reporting(E_ALL | E_STRICT);
     $config = new Config((object) self::getTestingConfigArray());
     $sp = new ServiceProvider($config);
     $sp->setFactory('plugins', function (ServiceProvider $c) {
         $pool = new InMemory();
         return new TestingPlugins($pool, $c->pluginSettingsCache);
     });
     $sp->setValue('mailer', new InMemoryTransport());
     $sp->siteSecret->setTestingSecret('z1234567890123456789012345678901');
     // persistentLogin service needs this set to instantiate without calling DB
     $sp->config->getCookieConfig();
     $app = new Application($sp);
     Application::setTestingApplication(true);
     Application::$_instance = $app;
     // loadCore bails on repeated calls, so we need to manually inject this to make
     // sure it happens before each test.
     $app->loadCore();
     _elgg_services($sp);
     // Invalidate memcache
     _elgg_get_memcache('new_entity_cache')->clear();
     self::$_mocks = null;
     // reset mocking service
 }