Create service with name

@param ServiceLocatorInterface $serviceLocator
@param                         $name
@param                         $requestedName
@return mixed
@throws MissingConfigurationException
17763
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        $config = $this->getConfig($serviceLocator);
        $config = $config[$requestedName];

        if (!isset($config['collectorFactory'])) {
            throw new MissingConfigurationException('Unable to create DataTable service: collectorFactory is missing');
        }

        if (!isset($config['columns']) || empty($config['columns'])) {
            throw new MissingConfigurationException('Unable to create DataTable service: columns are missing');
        }

        /** @var FactoryInterface $collectorFactory */
        $collectorFactory = new $config['collectorFactory'];

        $datatable = new DataTable(isset($config['id']) ? $config['id'] : $requestedName);
        $datatable->setCollector($collectorFactory->createService($serviceLocator));
        $columns = array();
        foreach ($config['columns'] as $columnConfig) {
            $columns[] = Column::factory($serviceLocator, $columnConfig);
        }
        $datatable->setColumns($columns);
        if (isset($config['classes'])) {
            $datatable->setClasses($config['classes']);
        }

        return $datatable;
    }
548356
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        $menu = strtolower(str_replace('DbNavigationMenu', '', $requestedName));

        $navigation = new DbNavigationFactory();
        $navigation->setName($menu);
        return $navigation->createService($serviceLocator);
    }
195945
public function canCreate(ContainerInterface $container, $requestedName)
    {
        $namespace = $this->getConfig($container)['namespace'];
        $ar = explode('_', $requestedName);

        return (count($ar) >= 2 && array_key_exists($ar[0], $namespace) && $ar[1] === 'model');
    }
519999
public function canCreate(ContainerInterface $serviceLocator, $requestedName)
    {
        if (substr($requestedName, -6) == self::WIDGET_SUFFIX) {
            /** @var $util \PageBuilder\Util\Widget */
            $util     = $serviceLocator->get('util\widget');
            $widgetId = str_replace(self::WIDGET_SUFFIX, '', $requestedName);

            return $util->widgetExist($widgetId);
        }

        return false;
    }
126354
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        /** @var ServiceManager $serviceManager */
        $serviceManager = $serviceLocator->getServiceLocator();

        $controller = new EnvironmentsController();

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

        /** @var UserRepositoryInterface $userRepository */
        $userRepository = $serviceManager->get('UserRepository');
        $controller->setUserRepository($userRepository);

        /** @var \KmbPmProxy\Service\EnvironmentInterface $pmProxyEnvironmentService */
        $pmProxyEnvironmentService = $serviceManager->get('KmbPmProxy\Service\Environment');
        $controller->setPmProxyEnvironmentService($pmProxyEnvironmentService);

        return $controller;
    }
685407
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        $config = $this->getConfig($serviceLocator)[$requestedName];
        /** @var $mongodb \MongoDb */
        $mongodb = $serviceLocator->get($config['database']);
        return $mongodb->selectCollection($config['collection']);
    }
484742
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName) {
        $interface = 'oat\search\base\command\OperatorConverterInterface';
        return (class_exists($requestedName) && in_array($interface , class_implements($requestedName)));
    }
1341686
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $config = $serviceLocator->get('Config');
        $appConfigConfiguration = isset($config['rumeaulib_appconfig']) ? $config['rumeaulib_appconfig'] : [];

        $service = new AppConfig($serviceLocator, $appConfigConfiguration);

        return $service;
    }
1223596
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        /** @var array $config */
        $config = $serviceLocator->get('Config')['eye4web_abac']['assertion_manager'];

        $pluginManager = new AssertionPluginManager(new Config($config));
        $pluginManager->setServiceLocator($serviceLocator);

        return $pluginManager;
    }
1221418
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        return $this->getContainer($serviceLocator)->has($requestedName);
    }
1257818
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $config = $serviceLocator->get('config');

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

        return new LocationTranslator($locations);
    }
1048529
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        /* @var $options FormAnnotationBuilder */
        $options = $serviceLocator->get(FormAnnotationBuilder::class);

        $cache = $serviceLocator->has($options->getCache())
            ? $serviceLocator->get($options->getCache())
            : null;

        $builder = new AnnotationBuilder($cache);

        if ($serviceLocator->has('FormElementManager')) {
            $serviceLocator->get('FormElementManager')->injectFactory($builder);
        }

        foreach ($options->getAnnotations() as $annotation) {
            $builder->getAnnotationParser()->registerAnnotation($annotation);
        }

        $events = $builder->getEventManager();
        foreach ($options->getListeners() as $listener) {
            $listener = $serviceLocator->has($listener)
                ? $serviceLocator->get($listener)
                : new $listener();

            if (!$listener instanceof ListenerAggregateInterface) {
                throw new RuntimeException(sprintf(
                    'Invalid event listener (%s) provided',
                    get_class($listener)
                ));
            }

            $events->attach($listener);
        }

        if (null !== $options->getPreserveDefinedOrder()) {
            $builder->setPreserveDefinedOrder($options->getPreserveDefinedOrder());
        }

        return $builder;
    }
1349551
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        $serviceManager = $serviceLocator instanceof AbstractPluginManager ?
            $serviceLocator->getServiceLocator() : $serviceLocator;

        $config = $serviceManager->get('config');

        $dataMapperSpec      = $config['thorr_persistence_dmm']['doctrine']['adapters'][$requestedName];
        $dataMapperClassName = is_string($dataMapperSpec) ? $dataMapperSpec : $dataMapperSpec['class'];

        $entityClass = array_search($requestedName, $config['thorr_persistence_dmm']['entity_data_mapper_map']);

        $objectManagerServiceName = isset($dataMapperSpec['object_manager']) ? $dataMapperSpec['object_manager'] : null;

        $objectManager = $this->getObjectManagerService($serviceManager, $objectManagerServiceName);

        $instance = new $dataMapperClassName($entityClass, $objectManager);

        if (! $instance instanceof DoctrineAdapter) {
            throw new Exception\ServiceNotCreatedException(sprintf(
                'Invalid data mapper type: "%s" is not a subtype of "%s"',
                $dataMapperClassName,
                DoctrineAdapter::class
            ));
        }

        return $instance;
    }
1319332
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $service = new Environment();

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

        return $service;
    }
249250
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $config             = $serviceLocator->get('config');
        $sessionOptions     = $serviceLocator->get(SessionOptions::class);
        $sessionConfig      = $config['uthando_session_manager']['config_options'] ?? [];
        /** @var SessionConfig $sessionConfigClass */
        $sessionConfigClass = $sessionOptions->getSessionConfigClass();
        $sessionConfigClass = new $sessionConfigClass() ;

        $sessionConfigClass->setOptions($sessionConfig);

        return $sessionConfigClass;
    }
375652
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        /** @var $env Environment */
        $env = $serviceLocator->get(Definition::SERVICE_ENVIRONMENT);

        $nameParts = explode('.', $requestedName);

        Assertion::min(count($nameParts), 3, sprintf("Given service bus alias %s is invalid. Format should be processing.(command|event)_bus.[target]", $requestedName));

        $busType = $nameParts[1];

        unset($nameParts[0]);
        unset($nameParts[1]);

        $address = implode('.', $nameParts);

        $busConfig = $this->getChannelConfigFor($env, $address);
        $target    = $this->getTargetFromAddress($address);

        $bus = ($busType === "command_bus")? new CommandBus() : new EventBus();

        $bus->utilize($this->getForwardToMessageDispatcher());

        $bus->utilize($this->getToMessageTranslator());

        $bus->utilize($this->getHandleWorkflowMessageStrategy());

        $bus->utilize($this->getInvokeProcessorStrategy());

        $bus->utilize(new ServiceLocatorProxy(Zf2ServiceManagerProxy::proxy($serviceLocator)));

        $messageHandler = $busConfig->stringValue('message_dispatcher', $target);

        if (! empty($messageHandler)) {
            $bus->utilize(new SingleTargetMessageRouter($messageHandler));
        } else {
            throw new \LogicException("Missing a message handler for the bus " . $requestedName);
        }

        foreach ($busConfig->arrayValue('utils') as $busUtil) {
            if (is_string($busUtil)) {
                $busUtil = $serviceLocator->get($busUtil);
            }

            $bus->utilize($busUtil);
        }

        return $bus;
    }
1194664
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        if (!array_key_exists($requestedName, $this->dataForModuleOptionsCreate)) {
            if (!$serviceLocator instanceof ModuleOptionsPluginManagerInterface) {
                return false;
            }
            /** @var ModuleOptionsPluginManagerInterface $serviceLocator  */
            $this->buildDataForModuleOptionsCreate($serviceLocator, $requestedName);
        }

        return false !== $this->dataForModuleOptionsCreate[$requestedName];
    }