@param array  $config
@param string $requestKey
@param array  $service

@return array
164677
private function getRequestParams(array $config, $requestKey, array $service)
    {
        $config = $this->getParamOrFail($config, 'requests');
        $config = $this->getParamOrFail($config, $requestKey);

        return [
            'path'    => $this->getParamOrFail($config, 'path'),
            'method'  => $this->getParam($config, 'method', 'GET'),
            'headers' => array_merge($service['headers'], $this->getParam($config, 'headers', [])),
            'query'   => array_merge($service['query'], $this->getParam($config, 'query', [])),
            'body'    => array_merge($service['body'], $this->getParam($config, 'body', [])),
            'version' => $this->getParam($config, 'version', $service['version']),
            'retries' => $this->getParam($config, 'retries', $service['retries']),
            'options' => array_merge($service['options'], $this->getParam($config, 'options', [])),
        ];
    }
386888
public function getService(string $serviceKey): DIServiceWrapper
    {
        /** @var DIServiceWrapper $service */
        foreach ($this->getServices() as $service) {
            if ($service->getKey() === $serviceKey) {
                return $service;
            }
        }
        throw new MissingServiceException("Service $serviceKey not found");
    }
734991
protected function parseConfig(array $config)
    {
        $config = $this->setHost($config);
        $config = $this->setPort($config);
        $config = $this->setProtocol($config);
        $config = $this->setServiceId($config);
        $config = $this->setTNS($config);
        $config = $this->setCharset($config);

        return $config;
    }
1081219
public static function factory($config = array()) {
        $default = array(
            'serverUrls' => null,
            'user' => null,
            'publicKey' => null,
            'privateKey' => null,
        );

        // Backwards-compatibility with old client where user === publicKey
        if (!isset($config['user']) && isset($config['publicKey'])) {
            $config['user'] = $config['publicKey'];
        }

        $required = array('serverUrls', 'publicKey', 'privateKey', 'user');
        $config = Collection::fromConfig($config, $default, $required);

        if (!is_array($serverUrls = $config->get('serverUrls')) || empty($serverUrls)) {
            throw new InvalidArgumentException('serverUrls must be an array');
        }

        // Create the client and attach the service description
        return new self($serverUrls[0], $config);
    }
443024
public function configureServiceManager(ServiceManager $serviceManager)
    {
        foreach ($this->config as $key => $value) {
            switch ($key) {
                case 'factories':
                    $this->configureFactories($serviceManager, $value);
                    break;
            }
        }
    }
978814
protected function loadConfig($serviceName)
    {
        if (!empty($this->config[$serviceName])) {
            return $this->config[$serviceName];
        } else {
            throw new OAuthServiceException('No configuration for ' . $serviceName . ' service');
        }
    }
416360
protected function getConfig($requestedName, ServiceLocatorInterface $services)
    {
        if ($this->configKey) {
            $config = $services->get('Config');
            if (!empty($config[$this->configKey][$requestedName])
                && is_array($config[$this->configKey][$requestedName])
            ) {
                return $config[$this->configKey][$requestedName];
            }
        }

        return [];
    }
701400
public function registerService($serviceName, ConfigObject $config, $overwrite = false)
    {
        /**
         * Check if service instance already exists
         */
        if ($this->registeredServices->keyExists($serviceName) && !$overwrite) {
            throw new ServiceManagerException(ServiceManagerException::SERVICE_NAME_ALREADY_EXISTS, [$serviceName]);
        }
        $this->registeredServices[$serviceName] = $config;

        if ($this->instantiatedServices->keyExists($serviceName) && $overwrite) {
            $this->instantiatedServices->removeKey($serviceName);
        }

        /**
         * Tagify service
         */
        foreach ($config->get('Tags', []) as $tag) {
            $tagServices = $this->taggedServices->key($tag, [], true);
            $tagServices[] = $serviceName;
            $this->taggedServices->key($tag, $tagServices);
        }

        return $this;
    }
989202
public function getQueryData(array $config = []) : array
    {
        if (empty($config)) {
            return [];
        }

        $resultSet = [];

        if (!empty($config['info']['finder'])) {
            $table = $config['info']['model'];

            $finder = $config['info']['finder']['name'];
            $options = Hash::get($config, 'info.finder.options', []);

            $resultSet = TableRegistry::get($table)->find($finder, $options);
        }

        if (empty($config['info']['finder']) && !empty($config['info']['query'])) {
            $resultSet = ConnectionManager::get('default')
                ->execute($config['info']['query'])
                ->fetchAll('assoc');
        }

        $columns = explode(',', $config['info']['columns']);

        $result = [];
        foreach ($resultSet as $item) {
            $row = [];
            foreach ($item as $column => $value) {
                if (in_array($column, $columns)) {
                    $row[$column] = $value;
                }
            }
            array_push($result, $row);
        }

        return $result;
    }
1082242
public function getParametersWithValue($requestValues)
    {
        // Final request parameters array
        $parameters = array();

        // Setting parameters
        foreach ($this->parameters as $paramKey => $paramDefaultValue) {
            // Overriding parameter value with the given one
            if (isset($requestValues[$paramKey]) && !empty($requestValues[$paramKey])) {
                $parameters[$paramKey] = $requestValues[$paramKey];
            } elseif (!empty($paramDefaultValue)) {
                $parameters[$paramKey] = $paramDefaultValue;
            }
        }

        // Returning populated array
        return $parameters;
    }
728405
protected function getSessionConfig(
        ServiceLocatorInterface $serviceLocator,
        $sessionConfig
    ) {
        if (empty($sessionConfig)
            || empty($sessionConfig['config'])
        ) {
            return new SessionConfig();
        }

        $class = '\Zend\Session\Config\SessionConfig';
        $options = [];

        if (isset($sessionConfig['config']['class'])
        ) {
            $class = $sessionConfig['config']['class'];
        }

        if (isset($sessionConfig['config']['options'])
        ) {
            $options = $sessionConfig['config']['options'];
        }

        /** @var \Zend\Session\Config\ConfigInterface $sessionConfigObject */
        if ($serviceLocator->has($class)) {
            $sessionConfigObject = $serviceLocator->get($class);
        } else {
            $sessionConfigObject = new $class();
        }

        if (!$sessionConfigObject instanceof ConfigInterface) {
            throw new InvalidArgumentException(
                'Session Config class must implement '
                . '\Zend\Session\Config\ConfigInterface'
            );
        }

        $sessionConfigObject->setOptions($options);

        return $sessionConfigObject;
    }
425845
protected function getExportConfig(Request $request)
    {
        $configKey = $request->get('configKey');
        if (!$configKey) {
            return [];
        }
        $session = $request->getSession();
        $selectedIds = null;
        $selectedColumns = null;
        if ($session) {
            $selectedIds = $session->get('export_selected_ids_'.$configKey);
            $selectedColumns = $session->get('export_selected_columns_'.$configKey);
        }
        $attributes = [];
        if (\is_array($selectedColumns)) {
            /** @var array $selectedColumns */
            foreach ($selectedColumns as $selectedColumn) {
                $attributes[$selectedColumn] = [
                    'enabled' => true,
                ];
            }
        }

        return [
            'selectedIds' => \is_array($selectedIds) ? implode('|', $selectedIds) : null,
            'onlySelectedEntities' => (bool) $selectedIds,
            'attributes' => $attributes,
        ];
    }
686317
private static function getBaseFromService($service, $serviceConfig)
    {
        if (isset($serviceConfig[0]['router-base']) && strlen($serviceConfig[0]['router-base']) > 0) {
            $base = $serviceConfig[0]['router-base'] . '/';
        } else {
            $parts = explode('.', $service);

            $entity = array_pop($parts);
            $module = $parts[1];

            $base = '/' . $module . '/' . $entity . '/';
        }

        return $base;
    }
237194
private function loadService($service, $serviceConfig)
    {
        list($app, $bundle, , $entity) = explode('.', $service);
        $resource = implode('.', array($app, $bundle, 'rest', $entity));

        $this->loadReadOnlyRoutes($service, $resource, $serviceConfig);
        if (!($serviceConfig[0] && array_key_exists('read-only', $serviceConfig[0]))) {
            $this->loadWriteRoutes($service, $resource, $serviceConfig);
        }
    }
1346712
public function register($serviceKey, ConfigurableService $service)
    {
        $parts = explode('/', $serviceKey, 2);
        if (count($parts) < 2) {
            throw new \common_Exception('Invalid servicekey '.$serviceKey);
        }
        $this->propagate($service);
        $this->services[$serviceKey] = $service;
        $success = $this->getConfig()->set($serviceKey, $service);
        if (!$success) {
            throw new \common_exception_Error('Unable to write '.$serviceKey);
        }
    }
180332
private function findServiceIdsByTag(ContainerBuilder $container, ServiceConfig $serviceConfig)
    {
        $tag = $serviceConfig->get(ServiceConfig::FIND_TAG);

        $serviceIds = array();

        foreach ($container->findTaggedServiceIds($tag) as $id => $services) {
            foreach ((array) $services as $service) {
                if (null === $name = $this->findName($service, $serviceConfig)) {
                    throw new \InvalidArgumentException(
                        sprintf(
                            'Service "%s" must define a name attribute like "key" or "type" for "%s" tags.',
                            $id,
                            $tag
                        )
                    );
                }

                $serviceIds[$service[$name]] = $id;
            }
        }

        return $serviceIds;
    }
210031
protected function findServiceIds(array $config, array &$serviceIds)
    {
        foreach ($config as $name => $value) {
            if (is_array($value)) {
                $this->findServiceIds($value, $serviceIds);
            } elseif ($name === 'service_id') {
                $serviceIds[] = $value;
            }
        }
    }