Create service

@param ServiceLocatorInterface $serviceLocator
@throws \InvalidArgumentException
@return mixed
510143
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        //Set up is ported from https://github.com/prooph/ProophEventStoreModule/blob/master/src/ProophEventStoreModule/Factory/EventStoreFactory.php
        $config = $serviceLocator->get("configuration");
        if (! isset($config['prooph.event_store'])) {
            throw new \InvalidArgumentException("Missing key prooph.event_store in application configuration");
        }
        $config = $config['prooph.event_store'];
        if (! isset($config['adapter'])) {
            throw new \InvalidArgumentException("Missing adapter configuration in prooph.event_store configuration");
        }

        $adapterType = isset($config['adapter']["type"])? $config['adapter']["type"] : 'Prooph\EventStore\Adapter\InMemoryAdapter';
        $adapterOptions = isset($config['adapter']["options"])? $config['adapter']["options"] : [];

        if ( $adapterType == 'Prooph\EventStore\Adapter\Zf2\Zf2EventStoreAdapter'
            && isset($adapterOptions['zend_db_adapter'])
            && is_string($adapterOptions['zend_db_adapter'])) {
            $config['adapter']['options']['zend_db_adapter'] = $serviceLocator->get($adapterOptions['zend_db_adapter']);
        }

        $featureManagerConfig = null;

        if (isset($config['feature_manager'])) {
            $featureManagerConfig = new Config($config['feature_manager']);
            unset($config['feature_manager']);
        }

        $esConfiguration = new Configuration($config);
        $featureManager = new ZF2FeatureManager($featureManagerConfig);
        $featureManager->setServiceLocator($serviceLocator);
        $esConfiguration->setFeatureManager(Zf2ServiceManagerProxy::proxy($featureManager));

        return new EventStore($esConfiguration);
    }
781006
public function createService( ServiceLocatorInterface $serviceLocator )
    {
        // Configure the definitions
        $config     = $serviceLocator->get( 'Configuration' );
        $srvConfig  = isset( $config['modules']['Grid\Paragraph'] )
                    ? $config['modules']['Grid\Paragraph']
                    : array();

        return new Customization(
            isset( $srvConfig['customizeSelectors'] )
                ? $srvConfig['customizeSelectors']
                : array(),
            isset( $srvConfig['customizeMapForms'] )
                ? $srvConfig['customizeMapForms']
                : array()
        );
    }
411472
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $caller = false;
        $appSm = method_exists($serviceLocator, 'getServiceLocator') ? call_user_func([$serviceLocator, 'getServiceLocator']) : null;
        if ($appSm && $appSm->has('Application')) {
            /** @var Application $app */
            $app = $appSm->get('Application');
            $callerEvent = new CallerEvent();
            $app->getEventManager()->trigger(CallerEvent::EVENT_RESOLVE_CALLER, $callerEvent);
            if ($callerEvent->getCaller()) {
                $caller = $callerEvent->getCaller();
            }
        }

        $w = new BasicWorkflow($caller);

        return $w;
    }
849145
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $taskResource = new Task();
        $taskResource->setTaskFinder($serviceLocator->getServiceLocator()->get(TaskFinder::class));
        return $taskResource;
    }
72672
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $resource = new MessageHandler();

        $resource->setFinder($serviceLocator->getServiceLocator()->get(MessageHandlerFinder::class));

        return $resource;
    }
373395
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $pathManager = $serviceLocator->get('pathmanager');
        $path = $pathManager->get('cache', 'doctrine');
        $cache = new FilesystemCache($path);

        return $cache;
    }
272531
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        /**
         * @var \Zend\ServiceManager\ServiceLocatorAwareTrait $serviceLocator
         */
        $sl = $serviceLocator->getServiceLocator();

        /**
         * @var \Mp3\InputFilter\Search $inputFilterSearch
         */
        $inputFilterSearch = $sl->get('InputFilterManager')
                                ->get('Mp3\InputFilter\Search');

        /**
         * @var \Mp3\Form\Search $formSearch
         */
        $formSearch = $sl->get('FormElementManager')
                         ->get('Mp3\Form\Search');

        /**
         * @var \Mp3\Service\Search $serviceSearch
         */
        $serviceSearch = $sl->get('Mp3\Service\Search');

        return new SearchController(
            $inputFilterSearch,
            $formSearch,
            $serviceSearch
        );
    }
140485
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $config = $serviceLocator->get('Config');
        $options = new SmtpOptions(isset($config['mail']['transport']['options'])
            ? $config['mail']['transport']['options']
            : []
        );
        return (new Smtp())->setOptions($options);
    }
833108
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $parser = $serviceLocator->get('ControllerNameParser');
        $logger = $serviceLocator->has('Logger') ? $serviceLocator->get('Logger') : null;

        return new ControllerResolver($serviceLocator, $parser, $logger);
    }
1257818
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $config = $serviceLocator->get('config');

        $locations = isset($config['locations'])? $config['locations'] : [];

        return new LocationTranslator($locations);
    }
1307839
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        /** @var EntityManagerInterface $objectManager */
        $objectManager = $serviceLocator->get('Doctrine\ORM\EntityManager');

        /** @var ValidatorPluginManager $validatorPluginManager */
        $validatorPluginManager = $serviceLocator->get('ValidatorManager');

        return new DoctrineORMProvider($objectManager, $validatorPluginManager);
    }
1230531
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $appServiceLocator = $serviceLocator instanceof AbstractPluginManager ? $serviceLocator->getServiceLocator() : $serviceLocator;

        /** @var array $appConfig */
        $appConfig = $appServiceLocator->get('config');
        $moduleConfig = array_key_exists(Module::CONFIG_KEY, $appConfig) ? $appConfig[Module::CONFIG_KEY] : [];

        return new ModuleOptions($moduleConfig);
    }
1137420
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $this->serviceLocator = $serviceLocator;

        $acl = $this->serviceLocator->getServiceLocator()
            ->get(Acl::class);

        $identity = $this->getIdentityHelper();

        $role = ($identity()) ? $identity()->getRole() : 'guest';

        $service = new Navigation();
        $service->setAcl($acl);
        $service->setRole($role);

        $service->setServiceLocator($this->serviceLocator->getServiceLocator());

        return $service;
    }
1235932
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        /** @var \Eye4web\Zf2Board\Options\ModuleOptions $options */
        $options = $serviceLocator->get('Eye4web\Zf2Board\Options\ModuleOptions');

        /** @var \Zend\Authentication\AuthenticationService $service */
        $service = $serviceLocator->get($options->getAuthenticationService());

        return $service;
    }
690969
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        /** @var MonologOptions $options */
        $options = $serviceLocator->get('EnliteMonologOptions');
        return $this->createLogger($serviceLocator, $options);
    }
812710
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        /** @var DoctrineObjectManagerInterface $doctrineObjectManager */
        $doctrineObjectManager = $serviceLocator->get(DoctrineObjectManagerInterface::class);

        /** @var ModuleOptionsPluginManagerInterface $moduleOptionsPluginManager */
        $moduleOptionsPluginManager = $serviceLocator->get(ModuleOptionsPluginManagerInterface::class);

        /** @var EntityManagerInterface $entityManager */
        $entityManager = $serviceLocator->get(EntityManagerInterface::class);

        return new EntityMapBuilder($doctrineObjectManager, $moduleOptionsPluginManager, $entityManager);
    }
773616
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $config         = $serviceLocator->get('ApplicationConfig');
        $allConnections = $libraryToConnMap = $configMap = array();

        // Early return
        if (!isset($config['datasource']['connections'])) {
            return new ConnectionManager($allConnections, $this->connectionClassMap);
        }

        foreach ($config['datasource']['connections'] as $name => $config) {
            $allConnections[$name]                = $config;
            $configMap[$config['library']][$name] = $config;
        }

        return new ConnectionManager($allConnections, $this->connectionClassMap);
    }