public function createSubject(SubjectConfigurationInterface $subjectConfiguration)
    {

        // load the subject instance from the DI container and set the subject configuration
        $subjectInstance = $this->container->get($subjectConfiguration->getId());
        $subjectInstance->setConfiguration($subjectConfiguration);

        // load the import adapter instance from the DI container and set it on the subject instance
        $importAdapter = $this->container->get($subjectConfiguration->getImportAdapter()->getId());

        // query whether or not we've found a factory or the instance itself
        if ($importAdapter instanceof ImportAdapterInterface) {
            $subjectInstance->setImportAdapter($importAdapter);
            // log a warning, that this is deprecated
            $this->getSystemLogger()->warning(
                sprintf(
                    'Direct injection of import adapter with DI ID "%s" is deprecated since version 3.0.0, please use factory instead',
                    $subjectConfiguration->getImportAdapter()->getId()
                )
            );
        } elseif ($importAdapter instanceof ImportAdapterFactoryInterface) {
            $subjectInstance->setImportAdapter($importAdapter->createImportAdapter($subjectConfiguration));
        } else {
            throw new \Exception(
                sprintf(
                    'Expected either an instance of ImportAdapterInterface or ImportAdapterFactoryInterface for DI ID "%s"',
                    $subjectConfiguration->getImportAdapter()->getId()
                )
            );
        }

        // query whether or not we've a subject instance that implements the exportable subject interface
        if ($subjectInstance instanceof ExportableSubjectInterface) {
            // load the export adapter instance from the DI container and set it on the subject instance
            $exportAdapter = $this->container->get($subjectConfiguration->getExportAdapter()->getId());

            // query whether or not we've found a factory or the instance itself
            if ($exportAdapter instanceof ExportAdapterInterface) {
                // inject the export adapter into the subject
                $subjectInstance->setExportAdapter($exportAdapter);
                // log a warning, that this is deprecated
                $this->getSystemLogger()->warning(
                    sprintf(
                        'Direct injection of export adapter with DI ID "%s" is deprecated since version 3.0.0, please use factory instead',
                        $subjectConfiguration->getExportAdapter()->getId()
                    )
                );
            } elseif ($exportAdapter instanceof ExportAdapterFactoryInterface) {
                $subjectInstance->setExportAdapter($exportAdapter->createExportAdapter($subjectConfiguration));
            } else {
                throw new \Exception(
                    sprintf(
                        'Expected either an instance of ExportAdapterInterface or ExportAdapterFactoryInterface for DI ID "%s"',
                        $subjectConfiguration->getExportAdapter()->getId()
                    )
                );
            }
        }

        // load te number converter instance from the DI container and set it on the subject instance
        if ($subjectInstance instanceof NumberConverterSubjectInterface) {
            $subjectInstance->setNumberConverter($this->numberConverterFactory->createNumberConverter($subjectConfiguration));
        }

        // load te date converter instance from the DI container and set it on the subject instance
        if ($subjectInstance instanceof DateConverterSubjectInterface) {
            $subjectInstance->setDateConverter($this->dateConverterFactory->createDateConverter($subjectConfiguration));
        }

        // load the filesystem adapter instance from the DI container and set it on the subject instance
        if ($subjectInstance instanceof FilesystemSubjectInterface) {
            $filesystemAdapterFactory = $this->container->get($subjectConfiguration->getFilesystemAdapter()->getId());
            $subjectInstance->setFilesystemAdapter($filesystemAdapterFactory->createFilesystemAdapter($subjectConfiguration));
        }

        // return the initialized subject instance
        return $subjectInstance;
    }
public function createSubject(SubjectConfigurationInterface $subjectConfiguration)
    {

        // load the subject instance from the DI container and set the subject configuration
        $subjectInstance = $this->container->get($subjectConfiguration->getId());
        $subjectInstance->setConfiguration($subjectConfiguration);

        // load the import adapter instance from the DI container and set it on the subject instance
        $importAdapter = $this->container->get($subjectConfiguration->getImportAdapter()->getId());

        // query whether or not we've found a factory or the instance itself
        if ($importAdapter instanceof ImportAdapterInterface) {
            $subjectInstance->setImportAdapter($importAdapter);
            // log a warning, that this is deprecated
            $this->getSystemLogger()->warning(
                sprintf(
                    'Direct injection of import adapter with DI ID "%s" is deprecated since version 3.0.0, please use factory instead',
                    $subjectConfiguration->getImportAdapter()->getId()
                )
            );
        } elseif ($importAdapter instanceof ImportAdapterFactoryInterface) {
            $subjectInstance->setImportAdapter($importAdapter->createImportAdapter($subjectConfiguration));
        } else {
            throw new \Exception(
                sprintf(
                    'Expected either an instance of ImportAdapterInterface or ImportAdapterFactoryInterface for DI ID "%s"',
                    $subjectConfiguration->getImportAdapter()->getId()
                )
            );
        }

        // query whether or not we've a subject instance that implements the exportable subject interface
        if ($subjectInstance instanceof ExportableSubjectInterface) {
            // load the export adapter instance from the DI container and set it on the subject instance
            $exportAdapter = $this->container->get($subjectConfiguration->getExportAdapter()->getId());

            // query whether or not we've found a factory or the instance itself
            if ($exportAdapter instanceof ExportAdapterInterface) {
                // inject the export adapter into the subject
                $subjectInstance->setExportAdapter($exportAdapter);
                // log a warning, that this is deprecated
                $this->getSystemLogger()->warning(
                    sprintf(
                        'Direct injection of export adapter with DI ID "%s" is deprecated since version 3.0.0, please use factory instead',
                        $subjectConfiguration->getExportAdapter()->getId()
                    )
                );
            } elseif ($exportAdapter instanceof ExportAdapterFactoryInterface) {
                $subjectInstance->setExportAdapter($exportAdapter->createExportAdapter($subjectConfiguration));
            } else {
                throw new \Exception(
                    sprintf(
                        'Expected either an instance of ExportAdapterInterface or ExportAdapterFactoryInterface for DI ID "%s"',
                        $subjectConfiguration->getExportAdapter()->getId()
                    )
                );
            }
        }

        // load te number converter instance from the DI container and set it on the subject instance
        if ($subjectInstance instanceof NumberConverterSubjectInterface) {
            $subjectInstance->setNumberConverter($this->numberConverterFactory->createNumberConverter($subjectConfiguration));
        }

        // load te date converter instance from the DI container and set it on the subject instance
        if ($subjectInstance instanceof DateConverterSubjectInterface) {
            $subjectInstance->setDateConverter($this->dateConverterFactory->createDateConverter($subjectConfiguration));
        }

        // load the filesystem adapter instance from the DI container and set it on the subject instance
        if ($subjectInstance instanceof FilesystemSubjectInterface) {
            $filesystemAdapterFactory = $this->container->get($subjectConfiguration->getFilesystemAdapter()->getId());
            $subjectInstance->setFilesystemAdapter($filesystemAdapterFactory->createFilesystemAdapter($subjectConfiguration));
        }

        // return the initialized subject instance
        return $subjectInstance;
    }
public function createSubject ( SubjectConfigurationInterface $ subjectConfiguration ) { // load the subject instance from the DI container and set the subject configuration $ subjectInstance = $ this -> container -> get ( $ subjectConfiguration -> getId ( ) ) ; $ subjectInstance -> setConfiguration ( $ subjectConfiguration ) ; // load the import adapter instance from the DI container and set it on the subject instance $ importAdapter = $ this -> container -> get ( $ subjectConfiguration -> getImportAdapter ( ) -> getId ( ) ) ; // query whether or not we've found a factory or the instance itself if ( $ importAdapter instanceof ImportAdapterInterface ) { $ subjectInstance -> setImportAdapter ( $ importAdapter ) ; // log a warning, that this is deprecated $ this -> getSystemLogger ( ) -> warning ( sprintf ( 'Direct injection of import adapter with DI ID "%s" is deprecated since version 3.0.0, please use factory instead' , $ subjectConfiguration -> getImportAdapter ( ) -> getId ( ) ) ) ; } elseif ( $ importAdapter instanceof ImportAdapterFactoryInterface ) { $ subjectInstance -> setImportAdapter ( $ importAdapter -> createImportAdapter ( $ subjectConfiguration ) ) ; } else { throw new \ Exception ( sprintf ( 'Expected either an instance of ImportAdapterInterface or ImportAdapterFactoryInterface for DI ID "%s"' , $ subjectConfiguration -> getImportAdapter ( ) -> getId ( ) ) ) ; } // query whether or not we've a subject instance that implements the exportable subject interface if ( $ subjectInstance instanceof ExportableSubjectInterface ) { // load the export adapter instance from the DI container and set it on the subject instance $ exportAdapter = $ this -> container -> get ( $ subjectConfiguration -> getExportAdapter ( ) -> getId ( ) ) ; // query whether or not we've found a factory or the instance itself if ( $ exportAdapter instanceof ExportAdapterInterface ) { // inject the export adapter into the subject $ subjectInstance -> setExportAdapter ( $ exportAdapter ) ; // log a warning, that this is deprecated $ this -> getSystemLogger ( ) -> warning ( sprintf ( 'Direct injection of export adapter with DI ID "%s" is deprecated since version 3.0.0, please use factory instead' , $ subjectConfiguration -> getExportAdapter ( ) -> getId ( ) ) ) ; } elseif ( $ exportAdapter instanceof ExportAdapterFactoryInterface ) { $ subjectInstance -> setExportAdapter ( $ exportAdapter -> createExportAdapter ( $ subjectConfiguration ) ) ; } else { throw new \ Exception ( sprintf ( 'Expected either an instance of ExportAdapterInterface or ExportAdapterFactoryInterface for DI ID "%s"' , $ subjectConfiguration -> getExportAdapter ( ) -> getId ( ) ) ) ; } } // load te number converter instance from the DI container and set it on the subject instance if ( $ subjectInstance instanceof NumberConverterSubjectInterface ) { $ subjectInstance -> setNumberConverter ( $ this -> numberConverterFactory -> createNumberConverter ( $ subjectConfiguration ) ) ; } // load te date converter instance from the DI container and set it on the subject instance if ( $ subjectInstance instanceof DateConverterSubjectInterface ) { $ subjectInstance -> setDateConverter ( $ this -> dateConverterFactory -> createDateConverter ( $ subjectConfiguration ) ) ; } // load the filesystem adapter instance from the DI container and set it on the subject instance if ( $ subjectInstance instanceof FilesystemSubjectInterface ) { $ filesystemAdapterFactory = $ this -> container -> get ( $ subjectConfiguration -> getFilesystemAdapter ( ) -> getId ( ) ) ; $ subjectInstance -> setFilesystemAdapter ( $ filesystemAdapterFactory -> createFilesystemAdapter ( $ subjectConfiguration ) ) ; } // return the initialized subject instance return $ subjectInstance ; }
Factory method to create new subject instance.

@param \TechDivision\Import\Configuration\SubjectConfigurationInterface $subjectConfiguration The subject configuration

@return \TechDivision\Import\Subjects\SubjectInterface The subject instance
Factory method to create new subject instance .