class Bootstrap (View source)

General purpose central core hyper Flow bootstrap class

Constants

MINIMUM_PHP_VERSION

Required PHP version

RUNLEVEL_COMPILETIME

RUNLEVEL_RUNTIME

Properties

protected ApplicationContext $context
protected array $requestHandlers
protected string $preselectedRequestHandlerClassName
protected RequestHandlerInterface $activeRequestHandler
static ObjectManagerInterface $staticObjectManager

The same instance like $objectManager, but static, for use in the proxy classes.

protected array $compiletimeCommands
protected array $earlyInstances

Methods

__construct(string $context, ClassLoader $composerAutoloader = null)

Constructor

void
run()

Bootstraps the minimal infrastructure, resolves a fitting request handler and then passes control over to that request handler.

void
shutdown(string $runlevel)

Initiates the shutdown procedure to safely close all connections, save modified data and commit other tasks necessary to cleanly exit Flow.

getContext()

Returns the context this bootstrap was started in.

void
registerRequestHandler(RequestHandlerInterface $requestHandler)

Registers a request handler which can possibly handle a request.

setPreselectedRequestHandlerClassName(string $className)

Preselects a specific request handler. If such a request handler exists, it will be used if it can handle the request – regardless of the priority of this or other request handlers.

getActiveRequestHandler()

Returns the request handler (if any) which is currently handling the request.

void
setActiveRequestHandler(RequestHandlerInterface $requestHandler)

Explicitly sets the active request handler.

void
registerCompiletimeCommand(string $commandIdentifier)

Registers a command specified by the given identifier to be called during compiletime (versus runtime). The related command controller must be totally aware of the limited functionality Flow provides at compiletime.

bool
isCompiletimeCommand(string $commandIdentifier)

Tells if the given command controller is registered for compiletime or not.

buildEssentialsSequence(string $identifier)

Builds a boot sequence with the minimum modules necessary for both, compiletime and runtime.

buildCompiletimeSequence()

Builds a boot sequence starting all modules necessary for the compiletime state.

buildRuntimeSequence()

Builds a boot sequence starting all modules necessary for the runtime state.

void
setEarlyInstance(string $objectName, object $instance)

Registers the instance of the specified object for an early boot stage.

getSignalSlotDispatcher()

Returns the signal slot dispatcher instance

object
getEarlyInstance(string $objectName)

Returns an instance which was registered earlier through setEarlyInstance()

array
getEarlyInstances()

Returns all registered early instances indexed by object name

getObjectManager()

Returns the object manager instance

resolveRequestHandler()

Iterates over the registered request handlers and determines which one fits best.

void
emitFinishedCompiletimeRun()

Emits a signal that the compile run was finished.

void
emitFinishedRuntimeRun()

Emits a signal that the runtime run was finished.

void
emitBootstrapShuttingDown(string $runLevel)

Emits a signal that the bootstrap finished and is shutting down.

void
defineConstants()

Defines various path constants used by Flow and if no root path or web root was specified by an environment variable, exits with a respective error message.

void
ensureRequiredEnvironment()

Checks PHP version and other parameters of the environment

static string
getEnvironmentConfigurationSetting(string $variableName)

Tries to find an environment setting with the following fallback chain:

Details

__construct(string $context, ClassLoader $composerAutoloader = null)

Constructor

Parameters

string $context

The application context, for example "Production" or "Development"

ClassLoader $composerAutoloader

Composer autoloader

void run()

Bootstraps the minimal infrastructure, resolves a fitting request handler and then passes control over to that request handler.

Return Value

void

void shutdown(string $runlevel)

Initiates the shutdown procedure to safely close all connections, save modified data and commit other tasks necessary to cleanly exit Flow.

This method should be called by a request handler after a successful run. Control is returned to the request handler which can exit the application as it sees fit.

Parameters

string $runlevel

one of the RUNLEVEL_* constants

Return Value

void

ApplicationContext getContext()

Returns the context this bootstrap was started in.

Return Value

ApplicationContext

The context encapsulated in an object, for example "Development" or "Development/MyDeployment"

void registerRequestHandler(RequestHandlerInterface $requestHandler)

Registers a request handler which can possibly handle a request.

All registered request handlers will be queried if they can handle a request when the bootstrap's run() method is called.

Parameters

RequestHandlerInterface $requestHandler

Return Value

void

setPreselectedRequestHandlerClassName(string $className)

Preselects a specific request handler. If such a request handler exists, it will be used if it can handle the request – regardless of the priority of this or other request handlers.

Parameters

string $className

RequestHandlerInterface getActiveRequestHandler()

Returns the request handler (if any) which is currently handling the request.

void setActiveRequestHandler(RequestHandlerInterface $requestHandler)

Explicitly sets the active request handler.

This method makes only sense to use during functional tests. During a functional test run the active request handler chosen by the bootstrap will be a command line request handler specialized on running functional tests. A functional test case can then set the active request handler to one which simulates, for example, an HTTP request.

Parameters

RequestHandlerInterface $requestHandler

Return Value

void

void registerCompiletimeCommand(string $commandIdentifier)

Registers a command specified by the given identifier to be called during compiletime (versus runtime). The related command controller must be totally aware of the limited functionality Flow provides at compiletime.

Parameters

string $commandIdentifier

Package key, controller name and command name separated by colon, e.g. "neos.flow:core:shell", wildcard for command name possible: "neos.flow:core:*"

Return Value

void

bool isCompiletimeCommand(string $commandIdentifier)

Tells if the given command controller is registered for compiletime or not.

Parameters

string $commandIdentifier

Package key, controller name and command name separated by colon, e.g. "neos.flow:cache:flush"

Return Value

bool

Sequence buildEssentialsSequence(string $identifier)

Builds a boot sequence with the minimum modules necessary for both, compiletime and runtime.

Parameters

string $identifier

Return Value

Sequence

Sequence buildCompiletimeSequence()

Builds a boot sequence starting all modules necessary for the compiletime state.

This includes all of the "essentials" sequence.

Return Value

Sequence

Sequence buildRuntimeSequence()

Builds a boot sequence starting all modules necessary for the runtime state.

This includes all of the "essentials" sequence.

Return Value

Sequence

void setEarlyInstance(string $objectName, object $instance)

Registers the instance of the specified object for an early boot stage.

On finalizing the Object Manager initialization, all those instances will be transferred to the Object Manager's registry.

Parameters

string $objectName

Object name, as later used by the Object Manager

object $instance

The instance to register

Return Value

void

Dispatcher getSignalSlotDispatcher()

Returns the signal slot dispatcher instance

Return Value

Dispatcher

object getEarlyInstance(string $objectName)

Returns an instance which was registered earlier through setEarlyInstance()

Parameters

string $objectName

Object name of the registered instance

Return Value

object

Exceptions

Exception

array getEarlyInstances()

Returns all registered early instances indexed by object name

Return Value

array

ObjectManagerInterface getObjectManager()

Returns the object manager instance

Return Value

ObjectManagerInterface

Exceptions

Exception

protected RequestHandlerInterface resolveRequestHandler()

Iterates over the registered request handlers and determines which one fits best.

Return Value

RequestHandlerInterface

A request handler

Exceptions

Exception

protected void emitFinishedCompiletimeRun()

Emits a signal that the compile run was finished.

Return Value

void

protected void emitFinishedRuntimeRun()

Emits a signal that the runtime run was finished.

Return Value

void

protected void emitBootstrapShuttingDown(string $runLevel)

Emits a signal that the bootstrap finished and is shutting down.

Parameters

string $runLevel

Return Value

void

protected void defineConstants()

Defines various path constants used by Flow and if no root path or web root was specified by an environment variable, exits with a respective error message.

Return Value

void

protected void ensureRequiredEnvironment()

Checks PHP version and other parameters of the environment

Return Value

void

static string getEnvironmentConfigurationSetting(string $variableName)

Tries to find an environment setting with the following fallback chain:

  • getenv with $variableName
  • getenv with REDIRECT_ . $variableName (this is for php cgi where environment variables from the http server get prefixed)
  • $SERVER[$variableName] (this is an alternative to set FLOW* environment variables if passing environment variables is not possible)
  • $SERVER[REDIRECT . $variableName] (again for php cgi environments)

Parameters

string $variableName

Return Value

string

or NULL if this variable was not set at all.