Elgg  Version 3.0
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
Elgg\Application Class Reference

Load, boot, and implement a front controller for an Elgg application. More...

Public Member Functions

 __construct (ServiceProvider $services)
 Constructor. More...
 
 bootCore ()
 Bootstrap the Elgg engine, loads plugins, and calls initial system events. More...
 
 getDbConfig ()
 Get the DB credentials. More...
 
 getDb ()
 Get a Database wrapper for performing queries without booting Elgg. More...
 
 run ()
 Routes the request, booting core if not yet booted. More...
 
 allowPathRewrite ()
 Allow plugins to rewrite the path. More...
 

Static Public Member Functions

static getInstance ()
 Get the global Application instance. More...
 
static setInstance (Application $application=null)
 Set the global Application instance. More...
 
static loadCore ()
 Define all Elgg global functions and constants, wire up boot events, but don't boot. More...
 
static requireSetupFileOnce ($file)
 Require a library/plugin file once and capture returned anonymous functions. More...
 
static start ()
 Start and boot the core. More...
 
static isCoreLoaded ()
 Are Elgg's global functions loaded? More...
 
static setGlobalConfig (Application $application)
 Make the global $CONFIG a reference to this application's config service. More...
 
static factory (array $spec=[])
 Create a new application. More...
 
static route (HttpRequest $request)
 Route a request. More...
 
static respond (ResponseBuilder $builder)
 Build and send a response. More...
 
static index ()
 Elgg's front controller. More...
 
static elggDir ()
 Returns a directory that points to the root of Elgg, but not necessarily the install root. More...
 
static projectDir ()
 Returns a directory that points to the project root, where composer is installed. More...
 
static install ()
 Renders a web UI for installing Elgg. More...
 
static upgrade ()
 Elgg upgrade script. More...
 
static migrate ()
 Runs database migrations. More...
 
static getMigrationSettings ()
 Returns configuration array for database migrations. More...
 
static isCli ()
 Is application running in CLI. More...
 
static getRequest ()
 Build request object. More...
 
static getStdIn ()
 Load console input interface. More...
 
static getStdOut ()
 Load console output interface. More...
 
static getStdErr ()
 Load console error output interface. More...
 
static getResponseTransport ()
 Build a transport for sending responses. More...
 

Public Attributes

const DEFAULT_LANG = 'en'
 
const DEFAULT_LIMIT = 10
 
 $_services
 

Static Public Attributes

static $_instance
 Reference to the loaded Application. More...
 

Detailed Description

Load, boot, and implement a front controller for an Elgg application.

To run as PHP CLI server: php -S localhost:8888 /full/path/to/elgg/index.php

The full path is necessary to work around this: https://bugs.php.net/bug.php?id=55726

Since
2.0.0

Definition at line 50 of file Application.php.

Constructor & Destructor Documentation

Elgg\Application::__construct ( ServiceProvider  $services)

Constructor.

Upon construction, no actions are taken to load or boot Elgg.

Parameters
ServiceProvider$servicesElgg services provider

Definition at line 110 of file Application.php.

Member Function Documentation

Elgg\Application::allowPathRewrite ( )

Allow plugins to rewrite the path.

Returns
void

Definition at line 665 of file Application.php.

Elgg\Application::bootCore ( )

Bootstrap the Elgg engine, loads plugins, and calls initial system events.

This method loads the full Elgg engine, checks the installation state, and triggers a series of events to finish booting Elgg:

  • { plugins_load system}
  • { plugins_boot system}
  • { init system}
  • { ready system}

Please note that the Elgg session is started after all plugins are loader, there will therefore be no information about a logged user available until plugins_load,system event is complete.

If Elgg is not fully installed, the browser will be redirected to an installation page.

Returns
void
Exceptions
InstallationException
InvalidParameterException
SecurityException
ClassException
DatabaseException

Definition at line 213 of file Application.php.

static Elgg\Application::elggDir ( )
static

Returns a directory that points to the root of Elgg, but not necessarily the install root.

See self::root() for that.

Returns
Directory

Definition at line 504 of file Application.php.

static Elgg\Application::factory ( array  $spec = [])
static

Create a new application.

Warning
You generally want to use getInstance().

For normal operation, you must use setInstance() and optionally setGlobalConfig() to wire the application to Elgg's global API.

Parameters
array$specSpecification for initial call.
Returns
self
Exceptions
ConfigurationException
InvalidArgumentException

The time with microseconds when the Elgg engine was started.

float

Definition at line 268 of file Application.php.

Elgg\Application::getDb ( )

Get a Database wrapper for performing queries without booting Elgg.

If settings has not been loaded, it will be loaded to configure the DB connection.

Note
Before boot, the Database instance will not yet be bound to a Logger.
Returns

Definition at line 238 of file Application.php.

Elgg\Application::getDbConfig ( )

Get the DB credentials.

We no longer leave DB credentials in the config in case it gets accidentally dumped.

Returns

Definition at line 225 of file Application.php.

static Elgg\Application::getInstance ( )
static

Get the global Application instance.

If not set, it's auto-created and wired to $CONFIG.

Returns
Application|null
Exceptions
ConfigurationException

Definition at line 83 of file Application.php.

static Elgg\Application::getMigrationSettings ( )
static

Returns configuration array for database migrations.

Returns
array

Definition at line 627 of file Application.php.

static Elgg\Application::getRequest ( )
static

Build request object.

Returns

Definition at line 694 of file Application.php.

static Elgg\Application::getResponseTransport ( )
static

Build a transport for sending responses.

Returns
ResponseTransport

Definition at line 745 of file Application.php.

static Elgg\Application::getStdErr ( )
static

Load console error output interface.

Returns
OutputInterface

Definition at line 732 of file Application.php.

static Elgg\Application::getStdIn ( )
static

Load console input interface.

Returns
InputInterface

Definition at line 706 of file Application.php.

static Elgg\Application::getStdOut ( )
static

Load console output interface.

Returns
OutputInterface

Definition at line 720 of file Application.php.

static Elgg\Application::index ( )
static

Elgg's front controller.

Handles basically all incoming URL requests.

Returns
Response|false True if Elgg will handle the request, false if the server should (PHP-CLI server)
Exceptions
ClassException
DatabaseException
InstallationException
InvalidParameterException
SecurityException

Definition at line 414 of file Application.php.

static Elgg\Application::install ( )
static

Renders a web UI for installing Elgg.

Returns
Response|false
Exceptions
InvalidParameterException

Definition at line 523 of file Application.php.

static Elgg\Application::isCli ( )
static

Is application running in CLI.

Returns
bool

Definition at line 679 of file Application.php.

static Elgg\Application::isCoreLoaded ( )
static

Are Elgg's global functions loaded?

Returns
bool

Definition at line 184 of file Application.php.

static Elgg\Application::loadCore ( )
static

Define all Elgg global functions and constants, wire up boot events, but don't boot.

This includes all the .php files in engine/lib (not upgrades). If a script returns a function, it is queued and executed at the end.

Returns
array

Definition at line 125 of file Application.php.

static Elgg\Application::migrate ( )
static

Runs database migrations.

Exceptions
InstallationException
Returns
bool

Definition at line 597 of file Application.php.

static Elgg\Application::projectDir ( )
static

Returns a directory that points to the project root, where composer is installed.

Returns
Directory

Definition at line 513 of file Application.php.

static Elgg\Application::requireSetupFileOnce (   $file)
static

Require a library/plugin file once and capture returned anonymous functions.

Parameters
string$fileFile to require
Returns
mixed

Definition at line 150 of file Application.php.

static Elgg\Application::respond ( ResponseBuilder  $builder)
static

Build and send a response.

If application is booted, we will use the response factory service, otherwise we will prepare a non-cacheable response

Parameters
ResponseBuilder$builderResponse builder
Returns
Response|false Sent response
Exceptions
InvalidParameterException

Definition at line 373 of file Application.php.

static Elgg\Application::route ( HttpRequest  $request)
static

Route a request.

Parameters
HttpRequest$requestRequest
Returns
Response|false
Exceptions
ClassException
DatabaseException
InstallationException
InvalidParameterException
SecurityException

Definition at line 335 of file Application.php.

Elgg\Application::run ( )

Routes the request, booting core if not yet booted.

Returns
Response|false False if Elgg wants the PHP CLI server to handle the request
Exceptions
ClassException
DatabaseException
InstallationException
InvalidParameterException
SecurityException

Definition at line 428 of file Application.php.

static Elgg\Application::setGlobalConfig ( Application  $application)
static

Make the global $CONFIG a reference to this application's config service.

Parameters
Application$applicationThe Application
Returns
void

Definition at line 249 of file Application.php.

static Elgg\Application::setInstance ( Application  $application = null)
static

Set the global Application instance.

Parameters
Application$applicationGlobal application
Returns
void

Definition at line 99 of file Application.php.

static Elgg\Application::start ( )
static
static Elgg\Application::upgrade ( )
static

Elgg upgrade script.

This script triggers any necessary upgrades. If the site has been upgraded to the most recent version of the code, no upgrades are run but the caches are flushed.

Upgrades use a table {db_prefix}upgrade_lock as a mutex to prevent concurrent upgrades.

The URL to forward to after upgrades are complete can be specified by setting $_GET['forward'] to a relative URL.

Returns
Response|false
Exceptions
ClassException
ConfigurationException
DatabaseException
InstallationException
InvalidParameterException
SecurityException

Definition at line 556 of file Application.php.

Member Data Documentation

Elgg\Application::$_instance
static

Reference to the loaded Application.

Definition at line 75 of file Application.php.

Elgg\Application::$_services

Definition at line 62 of file Application.php.

const Elgg\Application::DEFAULT_LANG = 'en'

Definition at line 54 of file Application.php.

const Elgg\Application::DEFAULT_LIMIT = 10

Definition at line 55 of file Application.php.


The documentation for this class was generated from the following file: