Bootstrap
class Bootstrap (View source)
General purpose central core hyper Flow bootstrap class
Constants
RUNLEVEL_COMPILETIME |
|
RUNLEVEL_RUNTIME |
|
Properties
protected ApplicationContext | $context | ||
protected RequestHandlerInterface> | $requestHandlers | ||
protected RequestHandlerInterface> | $preselectedRequestHandlerClassName | ||
protected RequestHandlerInterface | $activeRequestHandler | ||
static ObjectManagerInterface | $staticObjectManager | The same instance like $objectManager, but static, for use in the proxy classes. |
|
protected array<string,true> | $compiletimeCommands | ||
protected array<string|class-string,object> | $earlyInstances |
Methods
Constructor
Bootstraps the minimal infrastructure, resolves a fitting request handler and then passes control over to that request handler.
Initiates the shutdown procedure to safely close all connections, save modified data and commit other tasks necessary to cleanly exit Flow.
Returns the context this bootstrap was started in.
Registers a request handler which can possibly handle a request.
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.
Returns the request handler (if any) which is currently handling the request.
Explicitly sets the active request handler.
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.
Tells if the given command controller is registered for compiletime or not.
Builds a boot sequence with the minimum modules necessary for both, compiletime and runtime.
Builds a boot sequence starting all modules necessary for the compiletime state.
Builds a boot sequence starting all modules necessary for the runtime state.
Registers the instance of the specified object for an early boot stage.
Returns the signal slot dispatcher instance
Returns an instance which was registered earlier through setEarlyInstance()
Returns all registered early instances indexed by object name
Returns the object manager instance
Iterates over the registered request handlers and determines which one fits best.
Emits a signal that the compile run was finished.
Emits a signal that the runtime run was finished.
Emits a signal that the bootstrap finished and is shutting down.
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.
Checks PHP version and other parameters of the environment
Tries to find an environment setting with the following fallback chain:
Details
__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.
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.
ApplicationContext
getContext()
Returns the context this bootstrap was started in.
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.
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.
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.
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.
Sequence
buildEssentialsSequence(string $identifier)
Builds a boot sequence with the minimum modules necessary for both, compiletime and runtime.
Sequence
buildCompiletimeSequence()
Builds a boot sequence starting all modules necessary for the compiletime state.
This includes all of the "essentials" sequence.
Sequence
buildRuntimeSequence()
Builds a boot sequence starting all modules necessary for the runtime state.
This includes all of the "essentials" 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.
Dispatcher
getSignalSlotDispatcher()
Returns the signal slot dispatcher instance
T
getEarlyInstance(string $objectName)
Returns an instance which was registered earlier through setEarlyInstance()
array
getEarlyInstances()
Returns all registered early instances indexed by object name
ObjectManagerInterface
getObjectManager()
Returns the object manager instance
protected RequestHandlerInterface
resolveRequestHandler()
Iterates over the registered request handlers and determines which one fits best.
protected void
emitFinishedCompiletimeRun()
Emits a signal that the compile run was finished.
protected void
emitFinishedRuntimeRun()
Emits a signal that the runtime run was finished.
protected void
emitBootstrapShuttingDown(string $runLevel)
Emits a signal that the bootstrap finished and is shutting down.
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.
protected void
ensureRequiredEnvironment()
Checks PHP version and other parameters of the environment
static string|null
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)