Grav
extends Container
in package
Grav container is the heart of Grav.
Table of Contents
Properties
- $output : string
- $diMap : array<string|int, mixed>
- $initialized : array<string|int, mixed>
- $instance : static
- $middleware : array<string|int, mixed>
Methods
- __call() : mixed|null
- Magic Catch All Function
- cleanOutputBuffers() : void
- Clean any output buffers. Useful when exiting from the application.
- close() : void
- Terminates Grav request with a response.
- dispatchEvent() : object
- exit() : void
- fallbackUrl() : PageInterface|false
- This attempts to find media, other files, and download them
- fireEvent() : Event
- Fires an event with optional parameters.
- get() : mixed
- getRedirectResponse() : ResponseInterface
- Returns redirect response object from Grav.
- getVersion() : string
- Get Grav version.
- has() : bool
- header() : void
- Set response header.
- initializeCli() : $this
- Initialize CLI environment.
- instance() : Grav
- Return the Grav instance. Create it if it's not already instanced
- isSetup() : bool
- measureTime() : mixed
- Measure how long it takes to do an action.
- process() : void
- Process a request
- redirect() : void
- Terminates Grav request and redirects browser to another location.
- redirectLangSafe() : void
- Redirect browser to another location taking language into account (preferred)
- resetInstance() : void
- Reset the Grav instance.
- setLocale() : void
- Set the system locale based on the language and configuration
- setup() : $this
- Setup Grav instance using specific environment.
- shutdown() : void
- Set the final content length for the page and flush the buffer
- load() : static
- Initialize and return a Grav instance
- registerServices() : void
- Register all services Services are defined in the diMap. They can either only the class of a Service Provider or a pair of serviceKey => serviceClass that gets directly mapped into the container.
Properties
$output
public
string
$output
Processed output for the page.
$diMap
protected
static array<string|int, mixed>
$diMap
= [\Grav\Common\Service\AccountsServiceProvider::class, \Grav\Common\Service\AssetsServiceProvider::class, \Grav\Common\Service\BackupsServiceProvider::class, \Grav\Common\Service\ConfigServiceProvider::class, \Grav\Common\Service\ErrorServiceProvider::class, \Grav\Common\Service\FilesystemServiceProvider::class, \Grav\Common\Service\FlexServiceProvider::class, \Grav\Common\Service\InflectorServiceProvider::class, \Grav\Common\Service\LoggerServiceProvider::class, \Grav\Common\Service\OutputServiceProvider::class, \Grav\Common\Service\PagesServiceProvider::class, \Grav\Common\Service\RequestServiceProvider::class, \Grav\Common\Service\SessionServiceProvider::class, \Grav\Common\Service\StreamsServiceProvider::class, \Grav\Common\Service\TaskServiceProvider::class, 'browser' => \Grav\Common\Browser::class, 'cache' => \Grav\Common\Cache::class, 'events' => \Symfony\Component\EventDispatcher\EventDispatcher::class, 'exif' => \Grav\Common\Helpers\Exif::class, 'plugins' => \Grav\Common\Plugins::class, 'scheduler' => \Grav\Common\Scheduler\Scheduler::class, 'taxonomy' => \Grav\Common\Taxonomy::class, 'themes' => \Grav\Common\Themes::class, 'twig' => \Grav\Common\Twig\Twig::class, 'uri' => \Grav\Common\Uri::class]
Contains all Services and ServicesProviders that are mapped to the dependency injection container.
$initialized
protected
array<string|int, mixed>
$initialized
= []
$instance
protected
static static
$instance
The singleton instance
$middleware
protected
array<string|int, mixed>
$middleware
= ['multipartRequestSupport', 'initializeProcessor', 'pluginsProcessor', 'themesProcessor', 'requestProcessor', 'tasksProcessor', 'backupsProcessor', 'schedulerProcessor', 'assetsProcessor', 'twigProcessor', 'pagesProcessor', 'debuggerAssetsProcessor', 'renderProcessor']
All middleware processors that are processed in $this->process()
Methods
__call()
Magic Catch All Function
public
__call(string $method, array<string|int, mixed> $args) : mixed|null
Used to call closures.
Source: http://stackoverflow.com/questions/419804/closures-as-class-members
Parameters
- $method : string
- $args : array<string|int, mixed>
Attributes
- #[ReturnTypeWillChange]
Return values
mixed|nullcleanOutputBuffers()
Clean any output buffers. Useful when exiting from the application.
public
cleanOutputBuffers() : void
Please use $grav->close() and $grav->redirect() instead of calling this one!
close()
Terminates Grav request with a response.
public
close(ResponseInterface $response) : void
Please use this method instead of calling die(); or exit();. Note that you need to create a response object.
Parameters
- $response : ResponseInterface
dispatchEvent()
public
dispatchEvent(object $event) : object
Parameters
- $event : object
Return values
objectexit()
public
exit(ResponseInterface $response) : void
Use $grav->close() instead.
Parameters
- $response : ResponseInterface
fallbackUrl()
This attempts to find media, other files, and download them
public
fallbackUrl(string $path) : PageInterface|false
Parameters
- $path : string
Return values
PageInterface|falsefireEvent()
Fires an event with optional parameters.
public
fireEvent(string $eventName[, Event|null $event = null ]) : Event
Parameters
- $eventName : string
- $event : Event|null = null
Return values
Eventget()
public
get(string $id) : mixed
Parameters
- $id : string
getRedirectResponse()
Returns redirect response object from Grav.
public
getRedirectResponse(Route|string $route[, int|null $code = null ]) : ResponseInterface
Parameters
- $route : Route|string
-
Internal route.
- $code : int|null = null
-
Redirection code (30x)
Return values
ResponseInterfacegetVersion()
Get Grav version.
public
getVersion() : string
Return values
stringhas()
public
has(string $id) : bool
Parameters
- $id : string
Return values
boolheader()
Set response header.
public
header([ResponseInterface|null $response = null ]) : void
Parameters
- $response : ResponseInterface|null = null
initializeCli()
Initialize CLI environment.
public
initializeCli() : $this
Call after $grav->setup($environment)
- Load configuration
- Initialize logger
- Disable debugger
- Set timezone, locale
- Load plugins (call PluginsLoadedEvent)
- Set Pages and Users type to be used in the site
This method WILL NOT initialize assets, twig or pages.
Return values
$thisinstance()
Return the Grav instance. Create it if it's not already instanced
public
static instance([array<string|int, mixed> $values = [] ]) : Grav
Parameters
- $values : array<string|int, mixed> = []
Return values
GravisSetup()
public
isSetup() : bool
Return values
boolmeasureTime()
Measure how long it takes to do an action.
public
measureTime(string $timerId, string $timerTitle, callable $callback) : mixed
Parameters
- $timerId : string
- $timerTitle : string
- $callback : callable
Return values
mixed —Returns value returned by the callable.
process()
Process a request
public
process() : void
redirect()
Terminates Grav request and redirects browser to another location.
public
redirect(Route|string $route[, int|null $code = null ]) : void
Please use this method instead of calling header("Location: {$url}", true, 302); exit();.
Parameters
- $route : Route|string
-
Internal route.
- $code : int|null = null
-
Redirection code (30x)
redirectLangSafe()
Redirect browser to another location taking language into account (preferred)
public
redirectLangSafe(string $route[, int $code = null ]) : void
Parameters
- $route : string
-
Internal route.
- $code : int = null
-
Redirection code (30x)
resetInstance()
Reset the Grav instance.
public
static resetInstance() : void
setLocale()
Set the system locale based on the language and configuration
public
setLocale() : void
setup()
Setup Grav instance using specific environment.
public
setup([string|null $environment = null ]) : $this
Parameters
- $environment : string|null = null
Return values
$thisshutdown()
Set the final content length for the page and flush the buffer
public
shutdown() : void
load()
Initialize and return a Grav instance
protected
static load(array<string|int, mixed> $values) : static
Parameters
- $values : array<string|int, mixed>
Return values
staticregisterServices()
Register all services Services are defined in the diMap. They can either only the class of a Service Provider or a pair of serviceKey => serviceClass that gets directly mapped into the container.
protected
registerServices() : void