ServiceContainer
in package
Uses
PhpConfigFile
Service container
Table of Contents
Constants
- CONFIG_FILE_NAME = \Arikaim\Core\Utils\Path::CONFIG_PATH . 'service-providers.php'
- Default providers config file name
Properties
- $comments : array<string|int, mixed>
- Config array comments
- $container : Container
- Service container
- $serviceProviders : array<string|int, mixed>|null
- Service providers
- $configFileName : string
- Service providers config file
Methods
- __construct() : mixed
- Constructor
- get() : mixed|null
- Get service instance
- getProvider() : array<string|int, mixed>|null
- Get provider class
- getProviders() : array<string|int, mixed>
- Get service providers
- has() : bool
- Return true if service exists in container
- hasProvider() : bool
- Check if provider exists
- include() : array<string|int, mixed>|null
- Include file
- includeConfigFile() : array<string|int, mixed>|null
- Include config file
- includePhpArray() : array<string|int, mixed>|null
- Include php array
- load() : void
- Load service providers
- register() : bool
- Register service provider
- saveConfigFile() : bool
- Save config file
- unRegister() : bool
- UnRegister service
- with() : mixed
- Run closure with serice
- bindProvider() : bool
- Include service
- bindProviders() : void
- Bind providers
- exportArray() : string
- Export array as text
- exportConfig() : string
- Export config as text
- exportItem() : string
- Export item as text
- getCommentsText() : string
- Get array imtem comment as text
- resolveServiceDetails() : array<string|int, mixed>
- Resolve service edetails
- setComment() : void
- Set array key comment
- determineMaxTabs() : int
- Get max tabs count
- determineTabs() : int
- Get tabs count for array key
- getFileContent() : string
- Return config file content
- getFileContentHeader() : string
- Get config file header
- getTabs() : string
- Get tabs text
Constants
CONFIG_FILE_NAME
Default providers config file name
public
mixed
CONFIG_FILE_NAME
= \Arikaim\Core\Utils\Path::CONFIG_PATH . 'service-providers.php'
Properties
$comments
Config array comments
protected
array<string|int, mixed>
$comments
= []
$container
Service container
protected
Container
$container
$serviceProviders
Service providers
protected
array<string|int, mixed>|null
$serviceProviders
= null
$configFileName
Service providers config file
private
string
$configFileName
Methods
__construct()
Constructor
public
__construct([string|null $configFileName = null ]) : mixed
Parameters
- $configFileName : string|null = null
get()
Get service instance
public
get(string $name) : mixed|null
Parameters
- $name : string
Return values
mixed|nullgetProvider()
Get provider class
public
getProvider(string $name) : array<string|int, mixed>|null
Parameters
- $name : string
Return values
array<string|int, mixed>|nullgetProviders()
Get service providers
public
getProviders() : array<string|int, mixed>
Return values
array<string|int, mixed>has()
Return true if service exists in container
public
has(string $name) : bool
Parameters
- $name : string
Return values
boolhasProvider()
Check if provider exists
public
hasProvider(string $name) : bool
Parameters
- $name : string
Return values
boolinclude()
Include file
public
include(string $fileName) : array<string|int, mixed>|null
Parameters
- $fileName : string
-
Full file name
Return values
array<string|int, mixed>|nullincludeConfigFile()
Include config file
public
includeConfigFile(string $fileName[, string|null $extensionName = null ]) : array<string|int, mixed>|null
Parameters
- $fileName : string
- $extensionName : string|null = null
Return values
array<string|int, mixed>|nullincludePhpArray()
Include php array
public
includePhpArray(string $fileName) : array<string|int, mixed>|null
Parameters
- $fileName : string
Return values
array<string|int, mixed>|nullload()
Load service providers
public
load([bool $reload = false ]) : void
Parameters
- $reload : bool = false
register()
Register service provider
public
register(string|array<string|int, mixed> $details) : bool
Parameters
- $details : string|array<string|int, mixed>
Return values
boolsaveConfigFile()
Save config file
public
saveConfigFile(string $fileName, array<string|int, mixed> $data) : bool
Parameters
- $fileName : string
- $data : array<string|int, mixed>
Return values
boolunRegister()
UnRegister service
public
unRegister(string $name) : bool
Parameters
- $name : string
-
Name or provider class
Return values
boolwith()
Run closure with serice
public
with(string $name, Closure $callback) : mixed
Parameters
- $name : string
- $callback : Closure
bindProvider()
Include service
protected
bindProvider(string $name[, array<string|int, mixed>|null $provider = null ]) : bool
Parameters
- $name : string
- $provider : array<string|int, mixed>|null = null
Return values
boolbindProviders()
Bind providers
protected
bindProviders(array<string|int, mixed> $providersList) : void
Parameters
- $providersList : array<string|int, mixed>
exportArray()
Export array as text
protected
exportArray(array<string|int, mixed> $data, string $arrayKey[, int $currentTab = 1 ]) : string
Parameters
- $data : array<string|int, mixed>
- $arrayKey : string
- $currentTab : int = 1
Return values
stringexportConfig()
Export config as text
protected
exportConfig(array<string|int, mixed> $data) : string
Parameters
- $data : array<string|int, mixed>
Return values
stringexportItem()
Export item as text
protected
exportItem(string|int $key, mixed $value, int $maxTabs[, int $startTab = 1 ]) : string
Parameters
- $key : string|int
- $value : mixed
- $maxTabs : int
- $startTab : int = 1
Return values
stringgetCommentsText()
Get array imtem comment as text
protected
getCommentsText(string $key) : string
Parameters
- $key : string
Return values
stringresolveServiceDetails()
Resolve service edetails
protected
resolveServiceDetails(ServiceInterface|array<string|int, mixed> $details) : array<string|int, mixed>
Parameters
- $details : ServiceInterface|array<string|int, mixed>
Tags
Return values
array<string|int, mixed>setComment()
Set array key comment
protected
setComment(string $comment, string $key) : void
Parameters
- $comment : string
- $key : string
determineMaxTabs()
Get max tabs count
private
determineMaxTabs(array<string|int, mixed> $data[, int $tabSize = 4 ]) : int
Parameters
- $data : array<string|int, mixed>
- $tabSize : int = 4
Return values
intdetermineTabs()
Get tabs count for array key
private
determineTabs(string $key[, int $tabSize = 4 ]) : int
Parameters
- $key : string
- $tabSize : int = 4
Return values
intgetFileContent()
Return config file content
private
getFileContent(array<string|int, mixed> $data) : string
Parameters
- $data : array<string|int, mixed>
Return values
stringgetFileContentHeader()
Get config file header
private
getFileContentHeader() : string
Return values
stringgetTabs()
Get tabs text
private
getTabs(int $count) : string
Parameters
- $count : int