com\setasign\SetaSite

Di Application Di for SetaSite

File: /SetaSite/src/Di.php

You shouldn't use this class for anything (no typehints! no instanceof!). Use \com\setasign\SetaFramework\Di\Di instead!

Class hierarchy

  • com\setasign\SetaFramework\Application\ApplicationDi

Summary

Properties

$aliases

protected array \com\setasign\SetaFramework\Di\Di::$aliases = array()

An array of aliases configurations

$configures

protected array \com\setasign\SetaFramework\Di\Di::$configures = array()

An array of classes/interfaces configurations

$instances

protected array<string, null|object> \com\setasign\SetaFramework\Di\Di::$instances = array()

An internal cache of singleton instances


Methods

__construct()

public \com\setasign\SetaFramework\Application\ApplicationDi::__construct (
\com\setasign\SetaFramework\Application\ApplicationInterface $application,
\com\setasign\SetaFramework\Bootstrap\Bootstrap $bootstrap
)

ApplicationDi constructor.

Parameters
$application : \com\setasign\SetaFramework\Application\ApplicationInterface
 
$bootstrap : \com\setasign\SetaFramework\Bootstrap\Bootstrap
 

__sleep()

public \com\setasign\SetaFramework\Di\Di::__sleep (
void
): array

__wakeup()

public \com\setasign\SetaFramework\Di\Di::__wakeup (
void
): void

addAlias()

public \com\setasign\SetaFramework\Di\Di::addAlias (
string $name,
string|callable $classNameOrCallback,
array $params = array ( ),
bool $singleton = true
): self

Add an alias configuration

Parameters
$name : string
 
$classNameOrCallback : string|callable
 
$params : array
 
$singleton : bool
 
Exceptions

Throws \com\setasign\SetaFramework\Di\AlreadyDefinedException

addAliasWithInstancedObject()

public \com\setasign\SetaFramework\Di\Di::addAliasWithInstancedObject (
string $name,
?object $instance
): self
Parameters
$name : string
 
$instance : ?object
 

call()

public \com\setasign\SetaFramework\Di\Di::call (
callable $callable,
array $parameters = array ( )
): ?mixed

Call the callable and autowire the params.

Parameters
$callable : callable
 
$parameters : array
 
Return Values

Result of the callable

Exceptions

Throws \ReflectionException

callNewInstance()

public \com\setasign\SetaFramework\Di\Di::callNewInstance (
\com\setasign\SetaFramework\Di\class-string<\com\setasign\SetaFramework\Di\T> $className,
array $parameters = array ( )
): \com\setasign\SetaFramework\Di\T

Create a new instance of $className and autowire the params.

Parameters
$className : \com\setasign\SetaFramework\Di\class-string<\com\setasign\SetaFramework\Di\T>
 
$parameters : array
 
Exceptions

Throws \ReflectionException

clearInstance()

public \com\setasign\SetaFramework\Di\Di::clearInstance (
string $classNameOrAlias
): self
Parameters
$classNameOrAlias : string
 

configure()

public \com\setasign\SetaFramework\Di\Di::configure (
string $className,
array $params = array ( ),
bool $singleton = true
): self

Add a class/interface configuration

Parameters
$className : string
 
$params : array
 
$singleton : bool
 
Exceptions

Throws \com\setasign\SetaFramework\Di\AlreadyDefinedException

createBlockFactory()

protected Di::createBlockFactory (
Module\ModuleManager $moduleManager,
\com\setasign\SetaFramework\Application\ApplicationConfig $applicationConfig,
\com\setasign\SetaFramework\SimpleCache\ApplicationCacheHandler $cacheHandler,
\com\setasign\SetaFramework\Log\ApplicationLogHandler $logHandler
): Block\BlockFactory
Parameters
$moduleManager : Module\ModuleManager
 
$applicationConfig : \com\setasign\SetaFramework\Application\ApplicationConfig
 
$cacheHandler : \com\setasign\SetaFramework\SimpleCache\ApplicationCacheHandler
 
$logHandler : \com\setasign\SetaFramework\Log\ApplicationLogHandler
 
Exceptions

Throws \Throwable

createDatabase()

protected Di::createDatabase (
\com\setasign\SetaFramework\Database\DatabaseConnectionManager $connectionManager,
\com\setasign\SetaFramework\Application\ApplicationConfig $applicationConfig
): \com\setasign\SetaFramework\Database\Database
Parameters
$connectionManager : \com\setasign\SetaFramework\Database\DatabaseConnectionManager
 
$applicationConfig : \com\setasign\SetaFramework\Application\ApplicationConfig
 
Exceptions

Throws \com\setasign\SetaFramework\Database\ConnectionException

createPageHistory()

protected Di::createPageHistory (
\com\setasign\SetaFramework\Application\ApplicationConfig $applicationConfig,
\com\setasign\SetaFramework\Database\TableFactoryInterface $tableFactory
): Page\PageHistory
Parameters
$applicationConfig : \com\setasign\SetaFramework\Application\ApplicationConfig
 
$tableFactory : \com\setasign\SetaFramework\Database\TableFactoryInterface
 

createPageLocks()

protected Di::createPageLocks (
\com\setasign\SetaFramework\Application\ApplicationConfig $applicationConfig,
\com\setasign\SetaFramework\Database\TableFactoryInterface $tableFactory
): Page\PageLocks
Parameters
$applicationConfig : \com\setasign\SetaFramework\Application\ApplicationConfig
 
$tableFactory : \com\setasign\SetaFramework\Database\TableFactoryInterface
 
Exceptions

Throws \Throwable

createPages()

protected Di::createPages (
\com\setasign\SetaFramework\Application\ApplicationConfig $applicationConfig,
Config\PageTableNames $pageTableNames,
\com\setasign\SetaFramework\Database\TableFactoryInterface $tableFactory
): Page\Pages
Parameters
$applicationConfig : \com\setasign\SetaFramework\Application\ApplicationConfig
 
$pageTableNames : Config\PageTableNames
 
$tableFactory : \com\setasign\SetaFramework\Database\TableFactoryInterface
 
Exceptions

Throws \Throwable

createPersistantRegistry()

protected Di::createPersistantRegistry (
\com\setasign\SetaFramework\Database\Database $db,
\com\setasign\SetaFramework\Database\TableFactoryInterface $tableFactory
): \com\setasign\SetaFramework\Registry\PersistantDatabase
Parameters
$db : \com\setasign\SetaFramework\Database\Database
 
$tableFactory : \com\setasign\SetaFramework\Database\TableFactoryInterface
 
Exceptions

Throws \com\setasign\SetaFramework\Exception

Throws \com\setasign\SetaFramework\Database\Manager\TableSchemaBuilderException

createSession()

protected Di::createSession (
\com\setasign\SetaFramework\Request\ServerRequest $request,
\com\setasign\SetaFramework\Application\ApplicationConfig $applicationConfig
): \com\setasign\SetaFramework\Session\SessionInterface
Parameters
$request : \com\setasign\SetaFramework\Request\ServerRequest
 
$applicationConfig : \com\setasign\SetaFramework\Application\ApplicationConfig
 
Exceptions

Throws \com\setasign\SetaFramework\Session\SessionException

createUsers()

protected Di::createUsers (
\com\setasign\SetaFramework\Database\TableFactoryInterface $tableFactory,
Config\UserTableNames $userTableNames
): User\Users
Parameters
$tableFactory : \com\setasign\SetaFramework\Database\TableFactoryInterface
 
$userTableNames : Config\UserTableNames
 
Exceptions

Throws \Throwable

createView()

protected \com\setasign\SetaFramework\Application\ApplicationDi::createView (
\com\setasign\SetaFramework\Application\HttpApplicationInterface $application
): \com\setasign\SetaFramework\View\View
Parameters
$application : \com\setasign\SetaFramework\Application\HttpApplicationInterface
 

createViewTwigEnvironment()

protected \com\setasign\SetaFramework\Application\ApplicationDi::createViewTwigEnvironment (
\com\setasign\SetaFramework\Application\ApplicationInterface $application,
\com\setasign\SetaFramework\Bootstrap\Bootstrap $bootstrap,
\com\setasign\SetaFramework\Application\ApplicationConfig $applicationConfig,
\com\setasign\SetaFramework\Bootstrap\DomainName $domainName
): \com\setasign\SetaFramework\Controller\ViewTwigEnvironment
Parameters
$application : \com\setasign\SetaFramework\Application\ApplicationInterface
 
$bootstrap : \com\setasign\SetaFramework\Bootstrap\Bootstrap
 
$applicationConfig : \com\setasign\SetaFramework\Application\ApplicationConfig
 
$domainName : \com\setasign\SetaFramework\Bootstrap\DomainName
 

get()

public \com\setasign\SetaFramework\Di\Di::get (
string|\com\setasign\SetaFramework\Di\class-string<\com\setasign\SetaFramework\Di\T> $classNameOrAlias,
array $params = array ( ),
?bool $singleton = null
): object|\com\setasign\SetaFramework\Di\T

Get an instance by class name or alias.

If singleton is false, Di will create everytime a new object.

Di will remember up to one instance of every class/alias (except $singleton is false).

If you use an alias or a class that has a configuration, $params will be merged with the params of the configuration or alias.

If the di has already an instance, the $params will be ignored because no new object is created.

Parameters
$classNameOrAlias : string|\com\setasign\SetaFramework\Di\class-string<\com\setasign\SetaFramework\Di\T>
 
$params : array
 
$singleton : ?bool

Use null to use the configured value, or true/false to affect this behaviour

Exceptions

Throws \com\setasign\SetaFramework\Di\UnknownClassOrAliasException if alias wasn't found.

Throws \com\setasign\SetaFramework\Di\DiClassConstructionException if an exception occurs on constructing a new instance.

Throws \com\setasign\SetaFramework\Bootstrap\MaintenanceException

getArguments()

private \com\setasign\SetaFramework\Di\Di::getArguments (
array<string, \com\setasign\SetaFramework\Di\ReflectionParameter> $reflectionParameters,
array $parameters
): array
Parameters
$reflectionParameters : array<string, \com\setasign\SetaFramework\Di\ReflectionParameter>
 
$parameters : array
 

getByAlias()

private \com\setasign\SetaFramework\Di\Di::getByAlias (
string $name,
array $params,
?bool $singleton
): ?object

Get an instance by an alias

If the alias is definied to be a singleton the $params array is ignored if the instance was already created.

Parameters
$name : string
 
$params : array
 
$singleton : ?bool

Use null to use the configured value, or true/false to affect this behaviour

Exceptions

Throws \com\setasign\SetaFramework\Di\UnknownClassOrAliasException if alias wasn't found.

Throws \com\setasign\SetaFramework\Di\DiClassConstructionException if an exception occurs on constructing a new instance.

Throws \com\setasign\SetaFramework\Bootstrap\MaintenanceException

getByClassName()

private \com\setasign\SetaFramework\Di\Di::getByClassName (
\com\setasign\SetaFramework\Di\class-string<\com\setasign\SetaFramework\Di\T> $className,
array $params,
?bool $singleton
): \com\setasign\SetaFramework\Di\T

Get an instance by a class name

If the class is definied to be a singleton the $params array is ignored if the instance was already created.

Parameters
$className : \com\setasign\SetaFramework\Di\class-string<\com\setasign\SetaFramework\Di\T>
 
$params : array
 
$singleton : ?bool

Use null to use the configured value, or true/false to affect this behaviour

Exceptions

Throws \com\setasign\SetaFramework\Di\UnknownClassOrAliasException if alias wasn't found.

Throws \com\setasign\SetaFramework\Di\DiClassConstructionException if an exception occurs on constructing a new instance.

Throws \com\setasign\SetaFramework\Bootstrap\MaintenanceException

getDatabaseConnectionManager()

protected \com\setasign\SetaFramework\Application\ApplicationDi::getDatabaseConnectionManager (
\com\setasign\SetaFramework\Bootstrap\Bootstrap $bootstrap
): \com\setasign\SetaFramework\Database\DatabaseConnectionManager
Parameters
$bootstrap : \com\setasign\SetaFramework\Bootstrap\Bootstrap
 

getEventManager()

protected \com\setasign\SetaFramework\Application\ApplicationDi::getEventManager (
\com\setasign\SetaFramework\Bootstrap\Bootstrap $bootstrap
): \com\setasign\SetaFramework\EventManager\EventManager
Parameters
$bootstrap : \com\setasign\SetaFramework\Bootstrap\Bootstrap
 

getPermissionControl()

protected Di::getPermissionControl (
User\User $user
): \com\setasign\SetaFramework\Permissions\PermissionControl
Parameters
$user : User\User
 
Exceptions

Throws \ReflectionException

getReflectionParameters()

private \com\setasign\SetaFramework\Di\Di::getReflectionParameters (
array{0: \com\setasign\SetaFramework\Di\class-string|object, 1: string}|callable $callable
): array
Parameters
$callable : array{0: \com\setasign\SetaFramework\Di\class-string|object, 1: string}|callable
 
Exceptions

Throws \ReflectionException

hasAlias()

public \com\setasign\SetaFramework\Di\Di::hasAlias (
string $name
): bool

Checks whether the di contains a alias with this name

Parameters
$name : string
 

hasConfiguration()

public \com\setasign\SetaFramework\Di\Di::hasConfiguration (
string $className
): bool

Checks whether the di has a configuration for this class

Parameters
$className : string
 

hasInstance()

public \com\setasign\SetaFramework\Di\Di::hasInstance (
string $aliasOrClassname
): bool

Checks whether the di has an instance for this alias or className

Parameters
$aliasOrClassname : string
 

init()

protected Di::init (
void
): void

parentInjections()

public \com\setasign\SetaFramework\Di\Di::parentInjections (
string $parentClassName,
array $parameters = array ( )
): array
Parameters
$parentClassName : string
 
$parameters : array
 
Exceptions

Throws \ReflectionException

prepareParams()

private \com\setasign\SetaFramework\Di\Di::prepareParams (
array $params,
array $defaultParams = array ( )
): array

Prepares inject parameters

Internally aliases will be automatically resolved.

Parameters
$params : array
 
$defaultParams : array
 
Exceptions

Throws \com\setasign\SetaFramework\Di\UnknownClassOrAliasException

purgeName()

protected \com\setasign\SetaFramework\Di\Di::purgeName (
string $name
): string
Parameters
$name : string
 

remove()

public \com\setasign\SetaFramework\Di\Di::remove (
string $classNameOrAlias
): self

Removes all added configurations, aliases and instances with this name.

Parameters
$classNameOrAlias : string
 

setupApplicationCacheHandler()

protected \com\setasign\SetaFramework\Application\ApplicationDi::setupApplicationCacheHandler (
\com\setasign\SetaFramework\SimpleCache\CacheHandler $cacheHandler,
\com\setasign\SetaFramework\Application\HttpApplicationInterface $application
): \com\setasign\SetaFramework\SimpleCache\ApplicationCacheHandler
Parameters
$cacheHandler : \com\setasign\SetaFramework\SimpleCache\CacheHandler
 
$application : \com\setasign\SetaFramework\Application\HttpApplicationInterface
 

setupApplicationLogHandler()

protected \com\setasign\SetaFramework\Application\ApplicationDi::setupApplicationLogHandler (
\com\setasign\SetaFramework\Log\LogHandler $logHandler,
\com\setasign\SetaFramework\Application\HttpApplicationInterface $application
): \com\setasign\SetaFramework\Log\ApplicationLogHandler
Parameters
$logHandler : \com\setasign\SetaFramework\Log\LogHandler
 
$application : \com\setasign\SetaFramework\Application\HttpApplicationInterface
 

setupCacheHandler()

protected \com\setasign\SetaFramework\Application\ApplicationDi::setupCacheHandler (
\com\setasign\SetaFramework\Bootstrap\Bootstrap $bootstrap
): \com\setasign\SetaFramework\SimpleCache\CacheHandler
Parameters
$bootstrap : \com\setasign\SetaFramework\Bootstrap\Bootstrap
 

setupLogHandler()

protected \com\setasign\SetaFramework\Application\ApplicationDi::setupLogHandler (
\com\setasign\SetaFramework\Bootstrap\Bootstrap $bootstrap
): \com\setasign\SetaFramework\Log\LogHandler
Parameters
$bootstrap : \com\setasign\SetaFramework\Bootstrap\Bootstrap