Initialize

@param $instance
@param ServiceLocatorInterface $serviceLocator
@return mixed
164470
public function initialize($instance, ServiceLocatorInterface $serviceLocator)
    {
        if ($instance instanceof ActionController) {
            //We are dealing with a ControllerManager so we need to get the main service manger first
            $instance->setCommandBus($serviceLocator->getServiceLocator()->get('proophessor.command_bus'));
        }
    }
1132648
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $mainCacheManager = new MainCacheManager();
        $logger = $serviceLocator->get('Logger');
        $cacheStorage = $serviceLocator->get('CacheService');
        $dateTimeFactory = $serviceLocator->get('DateTimeFactory');

        $config = $serviceLocator->get('Config');
        if (array_key_exists('cache_manager', $config)) {
            foreach ($config['cache_manager'] as $key => $cacheManagerConfig) {
                if (array_key_exists('service', $cacheManagerConfig)) {
                    /** @var AbstractCacheManager $cacheManager */
                    $cacheManager = $serviceLocator->get($cacheManagerConfig['service']);
                    if ($cacheManager instanceof AbstractCacheManager) {
                        $cacheManager->setLogger($logger);
                        $cacheManager->setCacheStorage($cacheStorage);
                        $cacheManager->setDateTimeFactory($dateTimeFactory);
                        $cacheManager->setKey($key);
                        $cacheManager->setDescription(array_key_exists('description', $cacheManagerConfig) ? $cacheManagerConfig['description'] : $key);
                        if ($cacheManager->getSuffixBuilder() == null) {
                            $cacheManager->setSuffixBuilder(new DefaultSuffixBuilder());
                        }
                        if ($cacheManager->getDataContextBuilder() == null) {
                            $cacheManager->setDataContextBuilder(new DefaultDataContextBuilder());
                        }
                        $mainCacheManager->addCacheManager($key, $cacheManager);
                    } else {
                        $logger->warn("Invalid configuration for cache manager $key : service should extends KmbCache\\Service\\AbstractCacheManager");
                    }
                } else {
                    $logger->warn("Invalid configuration for cache manager $key : missing service");
                }
            }
        }
        return $mainCacheManager;
    }
159016
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        /** @var PluginManager $serviceLocator */
        /** @var ServiceManager $serviceManager */
        $serviceManager = $serviceLocator->getServiceLocator();

        $writeRevisionLog = new WriteRevisionLog();

        /** @var AuthenticationService $authenticationService */
        $authenticationService = $serviceManager->get('Zend\Authentication\AuthenticationService');
        $writeRevisionLog->setAuthenticationService($authenticationService);

        /** @var RevisionRepositoryInterface $revisionRepository */
        $revisionRepository = $serviceManager->get('RevisionRepository');
        $writeRevisionLog->setRevisionRepository($revisionRepository);

        /** @var DateTimeFactoryInterface $dateTimeFactory */
        $dateTimeFactory = $serviceManager->get('DateTimeFactory');
        $writeRevisionLog->setDateTimeFactory($dateTimeFactory);

        return $writeRevisionLog;
    }
439696
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $config = $serviceLocator->get('config');
        $config = new GuardLoaderConfig($config['guard']['instance_loader']);
        $loader = new InstanceLoader($config);

        return $loader;
    }
1257144
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $config = $serviceLocator->get('config');

        $controllerLoader = $serviceLocator->get('ControllerLoader');

        /** @var $systemConfig ProcessingConfig */
        $systemConfig = $serviceLocator->get('prooph.link.system_config');

        if ($serviceLocator->has('prooph.link.dashboard.widget_blacklist')) {
            $blacklist = $serviceLocator->get('prooph.link.dashboard.widget_blacklist');

            if (! $blacklist instanceof WidgetBlacklist) {
                throw new \RuntimeException("Widget blacklist should implement " . WidgetBlacklist::class
                . ". Got " . (is_object($blacklist))? get_class($blacklist) : gettype($blacklist));
            }
        }

        $controllers = [];

        $sortArr = [];

        if ($systemConfig->isConfigured()) {

            foreach ($config['prooph.link.dashboard'] as $widgetName => $widgetConfig) {

                if (isset($blacklist)) {
                    if ($blacklist->isWidgetOnList($widgetName)) {
                        continue;
                    }
                }

                if (! array_key_exists('controller', $widgetConfig)) {
                    throw new \RuntimeException('controller key missing in widget config: ' . $widgetName);
                }

                $sortArr[$widgetName] = (isset($widgetConfig['order']))? (int)$widgetConfig['order'] : 0;
            }

            asort($sortArr);

        } else {
            $sortArr['system_config_widget'] = 1;
        }

        foreach ($sortArr as $widgetName => $order) {
            $controller = $controllerLoader->get($config['prooph.link.dashboard'][$widgetName]['controller']);

            $controller->setWidgetConfig(new WidgetConfig($config['prooph.link.dashboard'][$widgetName]));

            $controllers[] = $controller;
        }

        return new DashboardProvider($controllers);
    }
1019435
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        if ($this->container !== null) {
            return $this->container;
        }

        $builder = new ContainerBuilder();
        $config = $this->getConfig($serviceLocator);
        $configFile = $this->getDefinitionsFilePath($config);
        $builder->addDefinitions($configFile);

        $useAnnotations = $this->shouldUseAnnotations($config);
        $builder->useAnnotations($useAnnotations);

        $acclimator = new ContainerAcclimator();
        $zfContainer = $acclimator->acclimate($serviceLocator);
        $builder->wrapContainer($zfContainer);

        /**
         * @var $cache Cache
         */
        $cache = $this->getCache($serviceLocator, $config);

        if ($cache) {
            $builder->setDefinitionCache($cache);
        }

        $this->container = $builder->build();

        return $this->container;
    }
1190279
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        /** @var PluginManager $serviceLocator */
        /** @var ServiceManager $serviceManager */
        $serviceManager = $serviceLocator->getServiceLocator();

        $writeLog = new WriteLog();

        /** @var AuthenticationService $authenticationService */
        $authenticationService = $serviceManager->get('Zend\Authentication\AuthenticationService');
        $writeLog->setAuthenticationService($authenticationService);

        /** @var LogRepositoryInterface $logRepository */
        $logRepository = $serviceManager->get('LogRepository');
        $writeLog->setLogRepository($logRepository);

        /** @var DateTimeFactoryInterface $dateTimeFactory */
        $dateTimeFactory = $serviceManager->get('DateTimeFactory');
        $writeLog->setDateTimeFactory($dateTimeFactory);

        return $writeLog;
    }
1186677
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $config = $serviceLocator->get('Config');
        $navigationConfig = $config['navigation'];
        $navigation = new Navigation($navigationConfig);
        return $navigation;
    }
411769
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $service = new Group();

        /** @var Environment $environmentService */
        $environmentService = $serviceLocator->get('KmbPuppet\Service\Environment');
        $service->setEnvironmentService($environmentService);

        return $service;
    }
579772
public function initialize($instance, ServiceLocatorInterface $serviceLocator)
	{
        if ($instance instanceof CurrencyExchangerAwareInterface) {
            if ($serviceLocator instanceof AbstractPluginManager) {
            	$serviceLocator = $serviceLocator->getServiceLocator();
            }

            $exchanger = $serviceLocator->get(CurrencyExchangerInterface::class);
            $instance->setCurrencyExchanger($exchanger);
        }
	}
1051023
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $config = $serviceLocator->get('config');

        if (! isset($config['prooph.link.message_queue'])) {
            throw new \RuntimeException('Missing prooph.link.message_queue key in application config.');
        }

        $config = $config['prooph.link.message_queue'];

        if (! isset($config['db'])) {
            throw new \RuntimeException('Missing db settings for prooph.link.message_queue in application config');
        }

        if ($config['db']['use_application_db']) {
            $connection = $serviceLocator->get('prooph.link.app.db');
        } else {
            if (! isset($config['db']['connection'])) {
                throw new \RuntimeException('Missing db connection settings for prooph.link.message_queue in application config');
            }

            $connection = DriverManager::getConnection($config['db']['connection']);
        }

        return new PersistentFactory(new DoctrineDriver($connection), new BernardSerializer());
    }
1117276
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        /* @var $proxyFactory \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory */
        $proxyFactory = $serviceLocator->get('OcraServiceManager\\ServiceManager\\AccessInterceptorProxyFactory');
        /* @var $locatorInterceptors \Closure[] */
        $locatorInterceptors = $serviceLocator->get('OcraServiceManager\\ServiceManager\\AccessInterceptors');

        return new ServiceLocatorDelegatorFactory($proxyFactory, $locatorInterceptors);
    }
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
        );
    }
1166811
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        /** @var HelperPluginManager $serviceLocator */
        $mainServiceManager = $serviceLocator->getServiceLocator();

        $helper = new EnvironmentSelect();

        /** @var EnvironmentRepositoryInterface $environmentRepository */
        $environmentRepository = $mainServiceManager->get('EnvironmentRepository');
        $helper->setEnvironmentRepository($environmentRepository);

        /** @var Application $application */
        $application = $mainServiceManager->get('Application');
        $helper->setRouteMatch($application->getMvcEvent()->getRouteMatch());

        return $helper;
    }
457589
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        /**
         * @var array $config
         */
        $config = $serviceLocator->get('config');

        /**
         * @var \Zend\View\HelperPluginManager $serverUrl
         */
        $serverUrl = $serviceLocator->get('ViewHelperManager');

        /**
         * @var \Zend\Mvc\I18n\Translator $translator
         */
        $translator = $serviceLocator->get('translator');

        return new Search(
            $config,
            $serverUrl,
            $translator
        );
    }
454749
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $config             = $serviceLocator->get('config');
        $sessionOptions     = $config['uthando_session_manager']['options'] ?? [];
        $options            = new SessionOptions($sessionOptions);

        return $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);
    }