PHP Class Symfony\Component\HttpKernel\Kernel

It manages an environment made of bundles.
Author: Fabien Potencier ([email protected])
Inheritance: implements Symfony\Component\HttpKernel\KernelInterface, implements Symfony\Component\HttpKernel\TerminableInterface
Mostrar archivo Open project: pmjones/php-framework-benchmarks Class Usage Examples

Protected Properties

Property Type Description
$booted
$bundleDirs
$bundleMap
$bundles
$classes
$container
$debug
$environment
$name
$rootDir
$startTime

Public Methods

Method Description
__clone ( )
__construct ( string $environment, boolean $debug ) Constructor.
addClassesToCache ( array $classes )
boot ( ) Boots the current kernel.
getBundle ( string $name, boolean $first = true ) : Symfony\Component\HttpKernel\Bundle\BundleInterface | Array Returns a bundle and optionally its descendants by its name.
getBundleDirs ( ) : array Gets the directories where bundles can be stored.
getBundleForClass ( string $class ) : string Returns the Bundle name for a given class.
getBundles ( ) : array Gets the registered bundle names.
getCacheDir ( )
getCacheDir ( ) : string Gets the cache directory.
getContainer ( )
getContainer ( ) : Symfony\Component\DependencyInjection\ContainerInterface Gets the current container.
getEnvironment ( )
getEnvironment ( ) : string Gets the environment.
getKernelParameters ( )
getLogDir ( )
getLogDir ( ) : string Gets the log directory.
getName ( )
getName ( ) : string Gets the name of the kernel
getRootDir ( )
getRootDir ( ) : string Gets the application root dir.
getSafeName ( )
getStartTime ( )
getStartTime ( ) : integer Gets the request start time (not available if debug is disabled).
handle ( Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true )
init ( )
isBooted ( ) : boolean Checks whether the current kernel has been booted or not.
isClassInActiveBundle ( string $class ) : boolean Checks if a given class name belongs to an active bundle.
isDebug ( )
isDebug ( ) : boolean Checks if debug mode is enabled.
loadClassCache ( string $name = 'classes', string $extension = '.php' ) Loads the PHP class cache.
locateResource ( string $name, string $dir = null, boolean $first = true ) : string | array Returns the file path for a given resource.
reboot ( ) Reboots the kernel.
registerBundleDirs ( )
registerBundles ( )
registerContainerConfiguration ( Symfony\Component\DependencyInjection\Loader\LoaderInterface $loader )
registerRootDir ( )
serialize ( )
setClassCache ( array $classes ) Used internally.
shutdown ( ) Shutdowns the kernel.
stripComments ( string $source ) : string Removes comments from a PHP source string.
unserialize ( $data )

Protected Methods

Method Description
buildContainer ( $class, $file )
buildContainer ( ) : ContainerBuilder Builds the service container.
dumpContainer ( Symfony\Component\Config\ConfigCache $cache, ContainerBuilder $container, string $class, string $baseClass ) Dumps the service container to PHP code in the cache.
getContainerBaseClass ( ) : string Gets the container's base class.
getContainerClass ( ) : string Gets the container class.
getContainerLoader ( Symfony\Component\DependencyInjection\ContainerInterface $container )
getContainerLoader ( Symfony\Component\DependencyInjection\ContainerInterface $container ) : Symfony\Component\Config\Loader\DelegatingLoader Returns a loader for the container.
getEnvParameters ( )
getEnvParameters ( ) : array Gets the environment parameters.
getHttpKernel ( ) : HttpKernel Gets a http kernel from the container
getKernelParameters ( ) : array Returns the kernel parameters.
initializeBundles ( ) Initializes the data structures related to the bundle management.
initializeContainer ( )
needsReload ( $class, $location )
writeCacheFile ( $file, $content )

Method Details

__clone() public method

public __clone ( )

__construct() public method

Constructor.
public __construct ( string $environment, boolean $debug )
$environment string The environment
$debug boolean Whether to enable debugging or not

addClassesToCache() public method

public addClassesToCache ( array $classes )
$classes array

boot() public method

This method boots the bundles, which MUST set the DI container.
public boot ( )

buildContainer() protected method

protected buildContainer ( $class, $file )

buildContainer() protected method

Builds the service container.
protected buildContainer ( ) : ContainerBuilder
return Symfony\Component\DependencyInjection\ContainerBuilder The compiled service container

dumpContainer() protected method

Dumps the service container to PHP code in the cache.
protected dumpContainer ( Symfony\Component\Config\ConfigCache $cache, ContainerBuilder $container, string $class, string $baseClass )
$cache Symfony\Component\Config\ConfigCache The config cache
$container Symfony\Component\DependencyInjection\ContainerBuilder The service container
$class string The name of the class to generate
$baseClass string The name of the container's base class

getBundle() public method

Returns a bundle and optionally its descendants by its name.
public getBundle ( string $name, boolean $first = true ) : Symfony\Component\HttpKernel\Bundle\BundleInterface | Array
$name string Bundle name
$first boolean Whether to return the first bundle only or together with its descendants
return Symfony\Component\HttpKernel\Bundle\BundleInterface | Array A BundleInterface instance or an array of BundleInterface instances if $first is false

getBundleDirs() public method

Gets the directories where bundles can be stored.
public getBundleDirs ( ) : array
return array An array of directories where bundles can be stored

getBundleForClass() public method

Returns the Bundle name for a given class.
public getBundleForClass ( string $class ) : string
$class string A class name
return string The Bundle name or null if the class does not belongs to a bundle

getBundles() public method

Gets the registered bundle names.
public getBundles ( ) : array
return array An array of registered bundle names

getCacheDir() public method

public getCacheDir ( )

getCacheDir() public method

Gets the cache directory.
public getCacheDir ( ) : string
return string The cache directory

getContainer() public method

public getContainer ( )

getContainer() public method

Gets the current container.
public getContainer ( ) : Symfony\Component\DependencyInjection\ContainerInterface
return Symfony\Component\DependencyInjection\ContainerInterface A ContainerInterface instance

getContainerBaseClass() protected method

All names except Container must be fully qualified.
protected getContainerBaseClass ( ) : string
return string

getContainerClass() protected method

Gets the container class.
protected getContainerClass ( ) : string
return string The container class

getContainerLoader() protected method

protected getContainerLoader ( Symfony\Component\DependencyInjection\ContainerInterface $container )
$container Symfony\Component\DependencyInjection\ContainerInterface

getContainerLoader() protected method

Returns a loader for the container.
protected getContainerLoader ( Symfony\Component\DependencyInjection\ContainerInterface $container ) : Symfony\Component\Config\Loader\DelegatingLoader
$container Symfony\Component\DependencyInjection\ContainerInterface The service container
return Symfony\Component\Config\Loader\DelegatingLoader The loader

getEnvParameters() protected method

protected getEnvParameters ( )

getEnvParameters() protected method

Only the parameters starting with "SYMFONY__" are considered.
protected getEnvParameters ( ) : array
return array An array of parameters

getEnvironment() public method

public getEnvironment ( )

getEnvironment() public method

Gets the environment.
public getEnvironment ( ) : string
return string The current environment

getHttpKernel() protected method

Gets a http kernel from the container
protected getHttpKernel ( ) : HttpKernel
return HttpKernel

getKernelParameters() public method

public getKernelParameters ( )

getKernelParameters() protected method

Returns the kernel parameters.
protected getKernelParameters ( ) : array
return array An array of kernel parameters

getLogDir() public method

public getLogDir ( )

getLogDir() public method

Gets the log directory.
public getLogDir ( ) : string
return string The log directory

getName() public method

public getName ( )

getName() public method

Gets the name of the kernel
public getName ( ) : string
return string The kernel name

getRootDir() public method

public getRootDir ( )

getRootDir() public method

Gets the application root dir.
public getRootDir ( ) : string
return string The application root dir

getSafeName() public method

public getSafeName ( )

getStartTime() public method

public getStartTime ( )

getStartTime() public method

Gets the request start time (not available if debug is disabled).
public getStartTime ( ) : integer
return integer The request start timestamp

handle() public method

public handle ( Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true )
$request Symfony\Component\HttpFoundation\Request

init() public method

public init ( )

initializeBundles() protected method

- the bundles property maps a bundle name to the bundle instance, - the bundleMap property maps a bundle name to the bundle inheritance hierarchy (most derived bundle first).
protected initializeBundles ( )

initializeContainer() protected method

protected initializeContainer ( )

isBooted() public method

Checks whether the current kernel has been booted or not.
public isBooted ( ) : boolean
return boolean $booted

isClassInActiveBundle() public method

Checks if a given class name belongs to an active bundle.
public isClassInActiveBundle ( string $class ) : boolean
$class string A class name
return boolean true if the class belongs to an active bundle, false otherwise

isDebug() public method

public isDebug ( )

isDebug() public method

Checks if debug mode is enabled.
public isDebug ( ) : boolean
return boolean true if debug mode is enabled, false otherwise

loadClassCache() public method

Loads the PHP class cache.
public loadClassCache ( string $name = 'classes', string $extension = '.php' )
$name string The cache name prefix
$extension string File extension of the resulting file

locateResource() public method

A Resource can be a file or a directory. The resource name must follow the following pattern: @/path/to/a/file.something where BundleName is the name of the bundle and the remaining part is the relative path in the bundle. If $dir is passed, and the first segment of the path is "Resources", this method will look for a file named: $dir//path/without/Resources before looking in the bundle resource folder.
public locateResource ( string $name, string $dir = null, boolean $first = true ) : string | array
$name string A resource name to locate
$dir string A directory where to look for the resource first
$first boolean Whether to return the first path or paths for all matching bundles
return string | array The absolute path of the resource or an array if $first is false

needsReload() protected method

protected needsReload ( $class, $location )

reboot() public method

This method is mainly useful when doing functional testing. It is a shortcut for the call to shutdown() and boot().
public reboot ( )

registerBundleDirs() abstract public method

abstract public registerBundleDirs ( )

registerBundles() abstract public method

abstract public registerBundles ( )

registerContainerConfiguration() abstract public method

abstract public registerContainerConfiguration ( Symfony\Component\DependencyInjection\Loader\LoaderInterface $loader )
$loader Symfony\Component\DependencyInjection\Loader\LoaderInterface

registerRootDir() abstract public method

abstract public registerRootDir ( )

serialize() public method

public serialize ( )

setClassCache() public method

Used internally.
public setClassCache ( array $classes )
$classes array

shutdown() public method

This method is mainly useful when doing functional testing.
public shutdown ( )

stripComments() public static method

We don't use the PHP php_strip_whitespace() function as we want the content to be readable and well-formatted.
public static stripComments ( string $source ) : string
$source string A PHP string
return string The PHP string with the comments removed

unserialize() public method

public unserialize ( $data )

writeCacheFile() protected method

protected writeCacheFile ( $file, $content )

Property Details

$booted protected_oe property

protected $booted

$bundleDirs protected_oe property

protected $bundleDirs

$bundleMap protected_oe property

protected $bundleMap

$bundles protected_oe property

protected $bundles

$classes protected_oe property

protected $classes

$container protected_oe property

protected $container

$debug protected_oe property

protected $debug

$environment protected_oe property

protected $environment

$name protected_oe property

protected $name

$rootDir protected_oe property

protected $rootDir

$startTime protected_oe property

protected $startTime