public function createInstance(NameAwareDescriptorInterface $objectDescriptor)
    {

        // try to load the reflection class
        $reflectionClass = $this->getReflectionClass($objectDescriptor->getClassName());

        // load the dependencies for the passed descriptor
        $dependencies = $this->loadDependencies($objectDescriptor);

        // check if we've a constructor
        if ($reflectionClass->hasMethod($methodName = '__construct') &&
            $reflectionClass->getMethod($methodName)->getParameters()
        ) {
            // query whether or not constructor parameters are available
            if (isset($dependencies['method'][$methodName])) {
                // create a new instance and pass the constructor args
                return $reflectionClass->newInstanceArgs($dependencies['method'][$methodName]);
            }
        }

        // create a new instance
        $instance = $reflectionClass->newInstance();

        // inject the dependencies using properties/methods
        $this->injectDependencies($objectDescriptor, $instance);

        // return the initialized instance
        return $instance;
    }
public function createInstance(NameAwareDescriptorInterface $objectDescriptor)
    {

        // try to load the reflection class
        $reflectionClass = $this->getReflectionClass($objectDescriptor->getClassName());

        // load the dependencies for the passed descriptor
        $dependencies = $this->loadDependencies($objectDescriptor);

        // check if we've a constructor
        if ($reflectionClass->hasMethod($methodName = '__construct') &&
            $reflectionClass->getMethod($methodName)->getParameters()
        ) {
            // query whether or not constructor parameters are available
            if (isset($dependencies['method'][$methodName])) {
                // create a new instance and pass the constructor args
                return $reflectionClass->newInstanceArgs($dependencies['method'][$methodName]);
            }
        }

        // create a new instance
        $instance = $reflectionClass->newInstance();

        // inject the dependencies using properties/methods
        $this->injectDependencies($objectDescriptor, $instance);

        // return the initialized instance
        return $instance;
    }
public function createInstance ( NameAwareDescriptorInterface $ objectDescriptor ) { // try to load the reflection class $ reflectionClass = $ this -> getReflectionClass ( $ objectDescriptor -> getClassName ( ) ) ; // load the dependencies for the passed descriptor $ dependencies = $ this -> loadDependencies ( $ objectDescriptor ) ; // check if we've a constructor if ( $ reflectionClass -> hasMethod ( $ methodName = '__construct' ) && $ reflectionClass -> getMethod ( $ methodName ) -> getParameters ( ) ) { // query whether or not constructor parameters are available if ( isset ( $ dependencies [ 'method' ] [ $ methodName ] ) ) { // create a new instance and pass the constructor args return $ reflectionClass -> newInstanceArgs ( $ dependencies [ 'method' ] [ $ methodName ] ) ; } } // create a new instance $ instance = $ reflectionClass -> newInstance ( ) ; // inject the dependencies using properties/methods $ this -> injectDependencies ( $ objectDescriptor , $ instance ) ; // return the initialized instance return $ instance ; }
Creates a new instance with the dependencies defined by the passed descriptor.

@param \AppserverIo\Psr\EnterpriseBeans\Description\NameAwareDescriptorInterface $objectDescriptor The object descriptor with the dependencies

@return object The instance
Creates a new instance with the dependencies defined by the passed descriptor .