Namespace: di

BX. di

Namespace BX.di holds an instance of the Container class.
This extension enables the use of the DI Container independently from the rest of Brixy framework. Brixy MVC framework already contains DI Container and doesn't need this file.

Source:

Methods

(static) getInstance (subject, injectionopt) → {Object}

Returns the instance of the subject.
In case of creating a new instance, it injects all dependencies that are specified by the SubjectType.injection property.
Optionally the injection argument may replace some of them.

Types of the subject:

  1. service name: creates/returns instance of the service (injection argument is not applied)
  2. module name: property module.Me is used as constructor of a new instance
  3. function: is used as constructor of a new instance
  4. object: is returned unchanged (injection argument is not applied)
Parameters:
Name Type Attributes Description
subject *

Service name or module name or constructor function or subject instance.

injection Array <optional>

Forced injection. Defined members will replace the corresponding Type.injection members. Not applicable for the service or object. (optional)

Throws:
  • Exception

Returns:
  • Object :
    • Instance of the subject.
Source:

(static) registerService (name, service)

Registers new service.

Parameters:
Name Type Description
name string

Service name.

service *

Module name (module.Me must refer to the object constructor) or service name or config object or service object.

Throws:
  • Exception

Source:

(static) registerServices (services)

Registers new services.

Parameters:
Name Type Description
services object
Throws:
  • Exception

Source: