src/GSOcr/Service/OcrServiceFactory.php
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $config = $serviceLocator->get('Configuration');
        if (!isset($config['ocr'])) {
            throw new Exception\RuntimeException('No "ocr" section available in configuration.');
        }
        if (!isset($config['ocr']['service'])) {
            throw new Exception\RuntimeException('No "service" specified in "ocr" section of configuration.');
        }
        $service = $serviceLocator->get($config['ocr']['service']);
        if (!$service instanceof OcrServiceInterface) {
            throw new Exception\RuntimeException('Provided service class is not a valid ocr service.');
        }
        if (isset($config['ocr']['config'])) {
            $service->setConfig($config['ocr']['config']);
        }
        return $service;
    }
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $config = $serviceLocator->get('Configuration');
        if (!isset($config['ocr'])) {
            throw new Exception\RuntimeException('No "ocr" section available in configuration.');
        }
        if (!isset($config['ocr']['service'])) {
            throw new Exception\RuntimeException('No "service" specified in "ocr" section of configuration.');
        }
        $service = $serviceLocator->get($config['ocr']['service']);
        if (!$service instanceof OcrServiceInterface) {
            throw new Exception\RuntimeException('Provided service class is not a valid ocr service.');
        }
        if (isset($config['ocr']['config'])) {
            $service->setConfig($config['ocr']['config']);
        }
        return $service;
    }
public function createService ( ServiceLocatorInterface $ serviceLocator ) { $ config = $ serviceLocator -> get ( 'Configuration' ) ; if ( ! isset ( $ config [ 'ocr' ] ) ) { throw new Exception \ RuntimeException ( 'No "ocr" section available in configuration.' ) ; } if ( ! isset ( $ config [ 'ocr' ] [ 'service' ] ) ) { throw new Exception \ RuntimeException ( 'No "service" specified in "ocr" section of configuration.' ) ; } $ service = $ serviceLocator -> get ( $ config [ 'ocr' ] [ 'service' ] ) ; if ( ! $ service instanceof OcrServiceInterface ) { throw new Exception \ RuntimeException ( 'Provided service class is not a valid ocr service.' ) ; } if ( isset ( $ config [ 'ocr' ] [ 'config' ] ) ) { $ service -> setConfig ( $ config [ 'ocr' ] [ 'config' ] ) ; } return $ service ; }
Create OCR service

@param ServiceLocatorInterface $serviceLocator
@return OcrServiceInterface
@throws InvalidArgumentException
Create OCR service