protected function parseDirectory($directory)
    {

        // check if we've found a valid directory
        if (is_dir($directory) === false) {
            return;
        }

        // load the object manager instance
        /** @var \AppserverIo\Psr\Di\ObjectManagerInterface $objectManager */
        $objectManager = $this->getApplication()->search(ObjectManagerInterface::IDENTIFIER);

        // check directory for classes we want to register
        /** @var \AppserverIo\Appserver\Core\Api\DeploymentService $service */
        $service = $this->getApplication()->newService('AppserverIo\Appserver\Core\Api\DeploymentService');
        $phpFiles = $service->globDir($directory . DIRECTORY_SEPARATOR . '*.php');

        // iterate all php files
        foreach ($phpFiles as $phpFile) {
            // iterate over all configured descriptors and try to load object description
            foreach ($this->getDescriptors() as $descriptor) {
                try {
                    // cut off the META-INF directory and replace OS specific directory separators
                    $relativePathToPhpFile = str_replace(DIRECTORY_SEPARATOR, '\\', str_replace($directory, '', $phpFile));

                    // now cut off the .php extension
                    $className = substr($relativePathToPhpFile, 0, -4);

                    // we need a reflection class to read the annotations
                    /** \AppserverIo\Lang\Reflection\ClassInterface $reflectionClass */
                    $reflectionClass = $objectManager->getReflectionClass($className);

                    // load the descriptor class
                    $descriptorClass = $descriptor->getNodeValue()->getValue();

                    // load the object descriptor and add it to the object manager
                    /** \AppserverIo\Psr\Deployment\DescriptorInterface $objectDescriptor */
                    if (class_exists($descriptorClass)) {
                        if ($objectDescriptor = $descriptorClass::newDescriptorInstance()->fromReflectionClass($reflectionClass)) {
                            $objectManager->addObjectDescriptor($objectDescriptor);
                        }
                    }

                // if class can not be reflected continue with next class
                } catch (\Exception $e) {
                    // log an error message
                    $this->getApplication()->getInitialContext()->getSystemLogger()->error($e->__toString());

                    // proceed with the next bean
                    continue;
                }
            }
        }
    }
protected function parseDirectory($directory)
    {

        // check if we've found a valid directory
        if (is_dir($directory) === false) {
            return;
        }

        // load the object manager instance
        /** @var \AppserverIo\Psr\Di\ObjectManagerInterface $objectManager */
        $objectManager = $this->getApplication()->search(ObjectManagerInterface::IDENTIFIER);

        // check directory for classes we want to register
        /** @var \AppserverIo\Appserver\Core\Api\DeploymentService $service */
        $service = $this->getApplication()->newService('AppserverIo\Appserver\Core\Api\DeploymentService');
        $phpFiles = $service->globDir($directory . DIRECTORY_SEPARATOR . '*.php');

        // iterate all php files
        foreach ($phpFiles as $phpFile) {
            // iterate over all configured descriptors and try to load object description
            foreach ($this->getDescriptors() as $descriptor) {
                try {
                    // cut off the META-INF directory and replace OS specific directory separators
                    $relativePathToPhpFile = str_replace(DIRECTORY_SEPARATOR, '\\', str_replace($directory, '', $phpFile));

                    // now cut off the .php extension
                    $className = substr($relativePathToPhpFile, 0, -4);

                    // we need a reflection class to read the annotations
                    /** \AppserverIo\Lang\Reflection\ClassInterface $reflectionClass */
                    $reflectionClass = $objectManager->getReflectionClass($className);

                    // load the descriptor class
                    $descriptorClass = $descriptor->getNodeValue()->getValue();

                    // load the object descriptor and add it to the object manager
                    /** \AppserverIo\Psr\Deployment\DescriptorInterface $objectDescriptor */
                    if (class_exists($descriptorClass)) {
                        if ($objectDescriptor = $descriptorClass::newDescriptorInstance()->fromReflectionClass($reflectionClass)) {
                            $objectManager->addObjectDescriptor($objectDescriptor);
                        }
                    }

                // if class can not be reflected continue with next class
                } catch (\Exception $e) {
                    // log an error message
                    $this->getApplication()->getInitialContext()->getSystemLogger()->error($e->__toString());

                    // proceed with the next bean
                    continue;
                }
            }
        }
    }
protected function parseDirectory ( $ directory ) { // check if we've found a valid directory if ( is_dir ( $ directory ) === false ) { return ; } // load the object manager instance /** @var \AppserverIo\Psr\Di\ObjectManagerInterface $objectManager */ $ objectManager = $ this -> getApplication ( ) -> search ( ObjectManagerInterface :: IDENTIFIER ) ; // check directory for classes we want to register /** @var \AppserverIo\Appserver\Core\Api\DeploymentService $service */ $ service = $ this -> getApplication ( ) -> newService ( 'AppserverIo\Appserver\Core\Api\DeploymentService' ) ; $ phpFiles = $ service -> globDir ( $ directory . DIRECTORY_SEPARATOR . '*.php' ) ; // iterate all php files foreach ( $ phpFiles as $ phpFile ) { // iterate over all configured descriptors and try to load object description foreach ( $ this -> getDescriptors ( ) as $ descriptor ) { try { // cut off the META-INF directory and replace OS specific directory separators $ relativePathToPhpFile = str_replace ( DIRECTORY_SEPARATOR , '\\' , str_replace ( $ directory , '' , $ phpFile ) ) ; // now cut off the .php extension $ className = substr ( $ relativePathToPhpFile , 0 , - 4 ) ; // we need a reflection class to read the annotations /** \AppserverIo\Lang\Reflection\ClassInterface $reflectionClass */ $ reflectionClass = $ objectManager -> getReflectionClass ( $ className ) ; // load the descriptor class $ descriptorClass = $ descriptor -> getNodeValue ( ) -> getValue ( ) ; // load the object descriptor and add it to the object manager /** \AppserverIo\Psr\Deployment\DescriptorInterface $objectDescriptor */ if ( class_exists ( $ descriptorClass ) ) { if ( $ objectDescriptor = $ descriptorClass :: newDescriptorInstance ( ) -> fromReflectionClass ( $ reflectionClass ) ) { $ objectManager -> addObjectDescriptor ( $ objectDescriptor ) ; } } // if class can not be reflected continue with next class } catch ( \ Exception $ e ) { // log an error message $ this -> getApplication ( ) -> getInitialContext ( ) -> getSystemLogger ( ) -> error ( $ e -> __toString ( ) ) ; // proceed with the next bean continue ; } } } }
Parses the passed directory for classes and instances that has to be registered
in the object manager.

@param string $directory The directory to parse

@return void
Parses the passed directory for classes and instances that has to be registered in the object manager .