protected function createInstance($className, $constructor = null, array $arguments = [], array $injections = [])
    {
        // Check for required dependency injections ...
        if (count($injections[Doozr_Di_Constants::INJECTION_TYPE_CONSTRUCTOR]) > 0) {
            // Get injections for constructor
            $constructorInjections = $this->parseInjections(
                Doozr_Di_Constants::INJECTION_TYPE_CONSTRUCTOR,
                $injections
            );

            // Process injections for constructor
            if (null !== $constructorInjections) {
                $arguments = $this->mergeArguments($constructorInjections, $arguments);
            }
        }

        // Get instance - for no dependency calls too
        $instance = $this->constructorInjection($className, $arguments, $constructor);

        // process only if $injections exists
        if (count($injections[Doozr_Di_Constants::INJECTION_TYPE_METHOD]) > 0) {

            // Get injections for methods
            $methodInjections = $this->parseInjections(
                Doozr_Di_Constants::INJECTION_TYPE_METHOD,
                $injections
            );

            if (null !== $methodInjections) {
                $this->methodInjection($instance, $methodInjections);
            }
        }

        // process only if $injections exists
        if (count($injections[Doozr_Di_Constants::INJECTION_TYPE_PROPERTY]) > 0) {

            // Get injections for property
            $propertyInjections = $this->parseInjections(
                Doozr_Di_Constants::INJECTION_TYPE_PROPERTY,
                $injections
            );

            // process injections for constructor
            if (null !== $propertyInjections) {
                $this->propertyInjection($instance, $propertyInjections);
            }
        }

        return $instance;
    }
protected function createInstance($className, $constructor = null, array $arguments = [], array $injections = [])
    {
        // Check for required dependency injections ...
        if (count($injections[Doozr_Di_Constants::INJECTION_TYPE_CONSTRUCTOR]) > 0) {
            // Get injections for constructor
            $constructorInjections = $this->parseInjections(
                Doozr_Di_Constants::INJECTION_TYPE_CONSTRUCTOR,
                $injections
            );

            // Process injections for constructor
            if (null !== $constructorInjections) {
                $arguments = $this->mergeArguments($constructorInjections, $arguments);
            }
        }

        // Get instance - for no dependency calls too
        $instance = $this->constructorInjection($className, $arguments, $constructor);

        // process only if $injections exists
        if (count($injections[Doozr_Di_Constants::INJECTION_TYPE_METHOD]) > 0) {

            // Get injections for methods
            $methodInjections = $this->parseInjections(
                Doozr_Di_Constants::INJECTION_TYPE_METHOD,
                $injections
            );

            if (null !== $methodInjections) {
                $this->methodInjection($instance, $methodInjections);
            }
        }

        // process only if $injections exists
        if (count($injections[Doozr_Di_Constants::INJECTION_TYPE_PROPERTY]) > 0) {

            // Get injections for property
            $propertyInjections = $this->parseInjections(
                Doozr_Di_Constants::INJECTION_TYPE_PROPERTY,
                $injections
            );

            // process injections for constructor
            if (null !== $propertyInjections) {
                $this->propertyInjection($instance, $propertyInjections);
            }
        }

        return $instance;
    }
protected function createInstance ( $ className , $ constructor = null , array $ arguments = [ ] , array $ injections = [ ] ) { // Check for required dependency injections ... if ( count ( $ injections [ Doozr_Di_Constants :: INJECTION_TYPE_CONSTRUCTOR ] ) > 0 ) { // Get injections for constructor $ constructorInjections = $ this -> parseInjections ( Doozr_Di_Constants :: INJECTION_TYPE_CONSTRUCTOR , $ injections ) ; // Process injections for constructor if ( null !== $ constructorInjections ) { $ arguments = $ this -> mergeArguments ( $ constructorInjections , $ arguments ) ; } } // Get instance - for no dependency calls too $ instance = $ this -> constructorInjection ( $ className , $ arguments , $ constructor ) ; // process only if $injections exists if ( count ( $ injections [ Doozr_Di_Constants :: INJECTION_TYPE_METHOD ] ) > 0 ) { // Get injections for methods $ methodInjections = $ this -> parseInjections ( Doozr_Di_Constants :: INJECTION_TYPE_METHOD , $ injections ) ; if ( null !== $ methodInjections ) { $ this -> methodInjection ( $ instance , $ methodInjections ) ; } } // process only if $injections exists if ( count ( $ injections [ Doozr_Di_Constants :: INJECTION_TYPE_PROPERTY ] ) > 0 ) { // Get injections for property $ propertyInjections = $ this -> parseInjections ( Doozr_Di_Constants :: INJECTION_TYPE_PROPERTY , $ injections ) ; // process injections for constructor if ( null !== $ propertyInjections ) { $ this -> propertyInjection ( $ instance , $ propertyInjections ) ; } } return $ instance ; }
Creates an instance of a class and returns it.

This method is intend to instantiate a class and pass the required dependencies to it.
The dependencies are pre-configured and passed to this method as $recipe. The className is
the name of the class to instantiate and arguments is an (optional) array of arguments
which are passed to the class as additional arguments when instantiating.

@param string $className   Name of the class being instantiated
@param string $constructor Name of constructor method (only required if not default = e.g. using Singleton)
@param array  $arguments   Arguments to pass to constructor when creating instance of $className
@param array  $injections  Injections to execute on instantiation process and via setter or property injections

@author Benjamin Carl <opensource@clickalicious.de>

@return object The new created instance.
Creates an instance of a class and returns it .