com\setasign\Konquadrat

Di Application Di for Konquadrat

File: /Konquadrat/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

createClassBuilder()

protected Di::createClassBuilder (
DirectorySettings $directorySettings,
LanguageManager $languageManager
): Config\Builder\ClassBuilder
Parameters
$directorySettings : DirectorySettings
 
$languageManager : LanguageManager
 
Exceptions

Throws \ReflectionException

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

createLanguageManager()

protected Di::createLanguageManager (
\com\setasign\SetaFramework\Application\ApplicationConfig $applicationConfig,
?\com\setasign\SetaFramework\Session\SessionInterface $session
): LanguageManager
Parameters
$applicationConfig : \com\setasign\SetaFramework\Application\ApplicationConfig
 
$session : ?\com\setasign\SetaFramework\Session\SessionInterface
 

createObjectConfig()

Parameters
$config : Config\Loader
 

createObjectConfigLoader()

protected Di::createObjectConfigLoader (
\com\setasign\SetaFramework\Registry\PersistantDatabase $persistantDatabase,
Konquadrat $konquadrat,
LanguageManager $languageManager
): Config\Loader
Parameters
$persistantDatabase : \com\setasign\SetaFramework\Registry\PersistantDatabase
 
$konquadrat : Konquadrat
 
$languageManager : LanguageManager
 
Exceptions

Throws \Smarty\Exception

Throws \Throwable

createObjectFinder()

protected Di::createObjectFinder (
\com\setasign\SetaFramework\Log\ApplicationLogHandler $logHandler
): Object\ObjectFinder
Parameters
$logHandler : \com\setasign\SetaFramework\Log\ApplicationLogHandler
 
Exceptions

Throws \Throwable

createObjectManager()

protected Di::createObjectManager (
\com\setasign\SetaFramework\Log\ApplicationLogHandler $logHandler
): Object\ObjectManager
Parameters
$logHandler : \com\setasign\SetaFramework\Log\ApplicationLogHandler
 
Exceptions

Throws \Throwable

createPersistantDatabaseManager()

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

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

Throws \com\setasign\SetaFramework\Exception

createPersistantRegistry()

protected Di::createPersistantRegistry (
Konquadrat $konquadrat,
\com\setasign\SetaFramework\Registry\PersistantDatabaseManager $persistantDatabaseManager
): \com\setasign\SetaFramework\Registry\PersistantDatabase
Parameters
$konquadrat : Konquadrat
 
$persistantDatabaseManager : \com\setasign\SetaFramework\Registry\PersistantDatabaseManager
 
Exceptions

Throws \com\setasign\SetaFramework\Exception

createSession()

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

createSmarty()

protected Di::createSmarty (
\com\setasign\SetaFramework\Application\ApplicationConfig $applicationConfig,
Smarty\Noun $noun,
Smarty\DateTime $dateTime,
Smarty\CssClasses $cssClasses,
\com\setasign\SetaFramework\View\Helper\CsrfFormField $csrfFormField,
\com\setasign\SetaFramework\Bootstrap\DomainName $domainName
): \Smarty\Smarty
Parameters
$applicationConfig : \com\setasign\SetaFramework\Application\ApplicationConfig
 
$noun : Smarty\Noun
 
$dateTime : Smarty\DateTime
 
$cssClasses : Smarty\CssClasses
 
$csrfFormField : \com\setasign\SetaFramework\View\Helper\CsrfFormField
 
$domainName : \com\setasign\SetaFramework\Bootstrap\DomainName
 
Exceptions

Throws \Smarty\Exception

createSwiftMailer()

protected Di::createSwiftMailer (
\com\setasign\SetaFramework\Application\ApplicationConfig $applicationConfig
): \Swift_Mailer
Parameters
$applicationConfig : \com\setasign\SetaFramework\Application\ApplicationConfig
 
Exceptions

Throws \Smarty\Exception

createSymfonyMailer()

protected Di::createSymfonyMailer (
\com\setasign\SetaFramework\Application\ApplicationConfig $applicationConfig
): \Symfony\Component\Mailer\MailerInterface
Parameters
$applicationConfig : \com\setasign\SetaFramework\Application\ApplicationConfig
 

createTransactionManager()

protected Di::createTransactionManager (
\com\setasign\SetaFramework\Database\Database $db,
\com\setasign\SetaFramework\Log\ApplicationLogHandler $logHandler
): Object\TransactionManager
Parameters
$db : \com\setasign\SetaFramework\Database\Database
 
$logHandler : \com\setasign\SetaFramework\Log\ApplicationLogHandler
 

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
 

createWakeupResolver()

Parameters
$konquadrat : Konquadrat
 
Exceptions

Throws \Throwable

createWorkflowFactory()

protected Di::createWorkflowFactory (
\com\setasign\SetaFramework\SimpleCache\ApplicationCacheHandler $cacheHandler
): Workflow\WorkflowFactoryInterface
Parameters
$cacheHandler : \com\setasign\SetaFramework\SimpleCache\ApplicationCacheHandler
 
Exceptions

Throws \Throwable

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
 

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