Configure a Maestrano marketplace from an array

@param $preset string The marketplace nid to configure
@param $settings array Configuration settings
@return true
@throws Maestrano_Config_Error
548470
public static function configureWithPreset($preset, $settings) {
        // Load from JSON file if filename provided
        if (is_string($settings) && is_file($settings)) {
            throw new Maestrano_Config_Error("Metadata files are not accepted anymore, please use the Developer Platform");
        }

        // Ensure preset is initialized
        if (!array_key_exists($preset, self::$config) || is_null(self::$config[$preset])) {
            self::$config[$preset] = array();
        }

        //-------------------------------
        // App Config
        //-------------------------------
        if (array_key_exists('nid', $settings)) {
            self::$config[$preset]['nid'] = $settings['nid'];
        }

        if (array_key_exists('marketplace', $settings)) {
            self::$config[$preset]['marketplace'] = $settings['marketplace'];
        }

        if (array_key_exists('environment', $settings)) {
            self::$config[$preset]['environment'] = $settings['environment'];
        }

        if (array_key_exists('app', $settings) && array_key_exists('host', $settings['app'])) {
            self::$config[$preset]['app.host'] = $settings['app']['host'];
        }

        if (array_key_exists('app', $settings) && array_key_exists('synchronization_start_path', $settings['app'])) {
            self::$config[$preset]['app.synchronization_start_path'] = $settings['app']['synchronization_start_path'];
        }

        if (array_key_exists('app', $settings) && array_key_exists('synchronization_toggle_path', $settings['app'])) {
            self::$config[$preset]['app.synchronization_toggle_path'] = $settings['app']['synchronization_toggle_path'];
        }

        if (array_key_exists('app', $settings) && array_key_exists('synchronization_status_path', $settings['app'])) {
            self::$config[$preset]['app.synchronization_status_path'] = $settings['app']['synchronization_status_path'];
        }

        //-------------------------------
        // API Config
        //-------------------------------
        if (array_key_exists('api', $settings) && array_key_exists('id', $settings['api'])) {
            self::$config[$preset]['api.id'] = $settings['api']['id'];
        }

        if (array_key_exists('api', $settings) && array_key_exists('key', $settings['api'])) {
            self::$config[$preset]['api.key'] = $settings['api']['key'];
        }

        if (array_key_exists('api', $settings) && array_key_exists('host', $settings['api'])) {
            self::$config[$preset]['api.host'] = $settings['api']['host'];
        }

        if (array_key_exists('api', $settings) && array_key_exists('base', $settings['api'])) {
            self::$config[$preset]['api.base'] = $settings['api']['base'];
        }

        // Get lang/platform version
        self::$config[$preset]['api.version'] = Maestrano::VERSION;
        self::$config[$preset]['api.lang'] = 'php';
        self::$config[$preset]['api.lang_version'] = phpversion() . " " . php_uname();

        // Build api.token from api.id and api.key
        self::$config[$preset]['api.token'] = self::$config[$preset]['api.id'] . ":" . self::$config[$preset]['api.key'];

        //-------------------------------
        // SSO Config
        //-------------------------------
        if (array_key_exists('sso', $settings) && array_key_exists('idm', $settings['sso'])) {
            self::$config[$preset]['sso.idm'] = $settings['sso']['idm'];
        }

        if (array_key_exists('sso', $settings) && array_key_exists('init_path', $settings['sso'])) {
            self::$config[$preset]['sso.init_path'] = $settings['sso']['init_path'];
        }

        if (array_key_exists('sso', $settings) && array_key_exists('consume_path', $settings['sso'])) {
            self::$config[$preset]['sso.consume_path'] = $settings['sso']['consume_path'];
        }

        if (array_key_exists('sso', $settings) && array_key_exists('idp', $settings['sso'])) {
            self::$config[$preset]['sso.idp'] = $settings['sso']['idp'];
        }

        if (array_key_exists('sso', $settings) && array_key_exists('x509_fingerprint', $settings['sso'])) {
            self::$config[$preset]['sso.x509_fingerprint'] = $settings['sso']['x509_fingerprint'];
        }

        if (array_key_exists('sso', $settings) && array_key_exists('x509_certificate', $settings['sso'])) {
            self::$config[$preset]['sso.x509_certificate'] = $settings['sso']['x509_certificate'];
        }

        //-------------------------------
        // Connec! Config
        //-------------------------------
        if (array_key_exists('connec', $settings) && array_key_exists('host', $settings['connec'])) {
            self::$config[$preset]['connec.host'] = $settings['connec']['host'];
        }

        if (array_key_exists('connec', $settings) && array_key_exists('base_path', $settings['connec'])) {
            self::$config[$preset]['connec.base_path'] = $settings['connec']['base_path'];
        }

        if (array_key_exists('connec', $settings) && array_key_exists('timeout', $settings['connec'])) {
            self::$config[$preset]['connec.timeout'] = $settings['connec']['timeout'];
        }

        //-------------------------------
        // Webhook Config - Account
        //-------------------------------
        if (array_key_exists('webhooks', $settings)
            && array_key_exists('account', $settings['webhooks'])
            && array_key_exists('group_path', $settings['webhooks']['account'])) {
            self::$config[$preset]['webhooks.account.group_path'] = $settings['webhooks']['account']['group_path'];
        }

        if (array_key_exists('webhooks', $settings)
            && array_key_exists('account', $settings['webhooks'])
            && array_key_exists('group_user_path', $settings['webhooks']['account'])) {
            self::$config[$preset]['webhooks.account.group_user_path'] = $settings['webhooks']['account']['group_user_path'];
        }

        //-------------------------------
        // Webhook Config - Connec
        //-------------------------------
        if (array_key_exists('webhooks', $settings)
            && array_key_exists('connec', $settings['webhooks'])
            && array_key_exists('external_ids', $settings['webhooks']['connec'])) {
            self::$config[$preset]['webhooks.connec.external_ids'] = $settings['webhooks']['connec']['external_ids'];
        }

        if (array_key_exists('webhooks', $settings)
            && array_key_exists('connec', $settings['webhooks'])
            && array_key_exists('initialization_path', $settings['webhooks']['connec'])) {
            self::$config[$preset]['webhooks.connec.initialization_path'] = $settings['webhooks']['connec']['initialization_path'];
        }

        if (array_key_exists('webhooks', $settings)
            && array_key_exists('connec', $settings['webhooks'])
            && array_key_exists('notification_path', $settings['webhooks']['connec'])) {
            self::$config[$preset]['webhooks.connec.notification_path'] = $settings['webhooks']['connec']['notification_path'];
        }

        return true;
    }
757959
public function setSettings($settings = [])
    {
        $original = $this->settings;
        $this->mergeSettings($settings, $this->settings);
        if ($this->settings != $original) {
            // @todo - Log Curl equivalent during test mode (adds overhead and risk so only do it during test)
            // if (!isset($this->settings['handler']) && class_exists(
            //         '\Namshi\Cuzzle\Middleware\CurlFormatterMiddleware'
            //     )) {
            //     $this->logger      = new Logger('guzzle.to.curl'); //initialize the logger
            //     $this->testHandler = new TestHandler(); //test logger handler
            //     $this->logger->pushHandler($this->testHandler);
            //
            //     $this->handler = HandlerStack::create();
            //     $this->handler->after('cookies', new \Namshi\Cuzzle\Middleware\CurlFormatterMiddleware($this->logger));
            //     $this->settings['handler'] = $this->handler;
            // }
            $this->client = new Client($this->settings);
        }
    }
630949
public function injectSettings(array $settings)
    {
        if (isset($settings['security']['cryptography']['RSAWalletServicePHP']['openSSLConfiguration'])
            && is_array($settings['security']['cryptography']['RSAWalletServicePHP']['openSSLConfiguration'])) {
            $this->openSSLConfiguration = $settings['security']['cryptography']['RSAWalletServicePHP']['openSSLConfiguration'];
        }

        if (isset($settings['security']['cryptography']['RSAWalletServicePHP']['keystorePath'])) {
            $this->keystorePathAndFilename = $settings['security']['cryptography']['RSAWalletServicePHP']['keystorePath'];
        } else {
            throw new MissingConfigurationException('The configuration setting Neos.Flow.security.cryptography.RSAWalletServicePHP.keystorePath is missing. Please specify it in your Settings.yaml file. Beware: This file must not be accessible by the public!', 1305711354);
        }

        if (isset($settings['security']['cryptography']['RSAWalletServicePHP']['paddingAlgorithm']) && is_int($settings['security']['cryptography']['RSAWalletServicePHP']['paddingAlgorithm'])) {
            $this->paddingAlgorithm = $settings['security']['cryptography']['RSAWalletServicePHP']['paddingAlgorithm'];
        } else {
            throw new SecurityException('The padding algorithm given in security.cryptography.RSAWalletServicePHP.paddingAlgorithm is not available.', 1556785429);
        }
    }
928038
public function settings(array $settings = null)
    {
        if ($settings !== null) {
            $this->settings = $settings;
        }

        return $this->settings + static::$globalSettings;
    }
1122833
public function initSettings(array $settings)
    {
        if (!isset($settings['tcp'])) {
            throw new \InvalidArgumentException('Tcp startup parameter is not configured，settings=' . \json_encode($settings));
        }

        if (!isset($settings['http'])) {
            throw new \InvalidArgumentException('HTTP startup parameters is not configured, settings=' . \json_encode($settings));
        }

        if (!isset($settings['server'])) {
            throw new \InvalidArgumentException('server startup parameters is not configured, settings=' . \json_encode($settings));
        }

        if (!isset($settings['setting'])) {
            throw new \InvalidArgumentException('"setting" parameters is not configured, settings=' . \json_encode($settings));
        }

        foreach ($settings['setting'] as $key => $value) {
            // path alias
            if ($value && \is_string($value) && $value[0] === '@') {
                $settings['setting'][$key] = App::getAlias($value);
            }
        }

        $this->setting = $settings['setting'];
        $this->tcpSetting = $settings['tcp'];
        $this->httpSetting = $settings['http'];
        $this->serverSetting = $settings['server'];

        // fix bug must to int
        if (isset($this->setting['task_ipc_mode'])) {
            $this->setting['task_ipc_mode'] = (int)$this->setting['task_ipc_mode'];
        }
        if (isset($this->setting['message_queue_key'])) {
            $this->setting['message_queue_key'] = (int)$this->setting['message_queue_key'];
        }
    }
874856
public function setAll(array $settings)
    {
        foreach ($settings as $name => $value) {
            if (is_string($name) && $this->exists($name)) { // avoid the logic exception
                $this->set($name, $value);
            }
        }
    }
455141
public function setS3Client($settings)
	{
		$storage = new S3StorageHelper;
		$storage->region = $settings['region'];
		$storage->bucket = $settings['bucket'];
		$storage->credentials = $settings['credentials'];
		$storage->defaultAcl = $settings['defaultAcl'];

		if(isset($settings['cdnHostname'])) {
			$storage->cdnHostname = $settings['cdnHostname'];
		}
		if(isset($settings['debug'])) {
			$storage->debug = $settings['debug'];
		}
		if(isset($settings['options'])) {
			$storage->options = $settings['options'];
		}
		$storage->init();

		return $storage;
	}
520049
public function setSelectizeOptions(array $settings)
    {
        $this->selectizeOptions = array_merge(
            $this->defaultSelectizeOptions(),
            $this->parseSelectizeOptions($settings)
        );

        return $this;
    }
128534
public function setControllerSettings(array $settings, $override = false)
    {
        $this->controllerSettings = $override ? $settings : array_replace($this->controllerSettings, $settings);
    }
821042
public static function paramWithPreset($preset, $parameter) {
        if (empty($preset)) {
            throw new Maestrano_Config_Error('Empty preset name, make sure you are using \'Maestrano::with($marketplace)->someMethod()\'');
        }

        if (!array_key_exists($preset, self::$config)) {
            throw new Maestrano_Config_Error("Maestrano was not configured for preset '$preset'");
        }

        if (array_key_exists($parameter, self::$config[$preset])) {
            return self::$config[$preset][$parameter];
        } else {
            throw new Maestrano_Config_Error("Preset '$preset' does not contain parameter '$parameter'");
        }
    }
130589
public function setLinkDefaults(array $Settings = [])
    {
        if (isset($Settings["R"])) {
            $this->Default["LinkR"] = $Settings["R"];
        }
        if (isset($Settings["G"])) {
            $this->Default["LinkG"] = $Settings["G"];
        }
        if (isset($Settings["B"])) {
            $this->Default["LinkB"] = $Settings["B"];
        }
        if (isset($Settings["Alpha"])) {
            $this->Default["LinkAlpha"] = $Settings["Alpha"];
        }
    }
602668
protected function set_preset() {

		// Set preset from the choices.
		$this->preset = $this->choices;

		// We're using a flat select.
		foreach ( $this->choices as $key => $args ) {
			$this->choices[ $key ] = $args['label'];
		}
	}
1109892
public function injectSettings(array $settings)
    {
        $this->settings = $settings['persistence'];
        if (!is_array($this->settings['doctrine'])) {
            throw new InvalidConfigurationException(sprintf('The Neos.Flow.persistence.doctrine settings need to be an array, %s given.', gettype($this->settings['doctrine'])), 1392800005);
        }
    }
414743
public static function with($preset)
    {
        $cname = get_called_class();

        if (!array_key_exists($cname, self::$preset_cache) || is_null(self::$preset_cache[$cname])) {
            self::$preset_cache[$cname] = array();
        }

        if (!array_key_exists($preset, self::$preset_cache[$cname]) || is_null(self::$preset_cache[$cname][$preset])) {
            self::$preset_cache[$cname][$preset] = new Maestrano_Util_PresetProxy(get_called_class(), $preset);
        }

        return self::$preset_cache[$cname][$preset];
    }
603907
protected function setSettings(array $settings): void
    {
        $this->server->set(array_merge($this->defaultSettings, $this->settings, $settings));
    }
26126
public static function configure($settings)
    {
        if (isset($settings['client_id'])) {
            self::configureOAuth($settings);
        } else {
            self::configureBasicAuth($settings);
        }
    }
593593
public function configure(array $settings = [], $dev = false)
    {
        $this->settings = [
            'dev'        => $dev,
            'paths'      => array_get($settings, 'paths'),
            'proxy_path' => array_get($settings, 'proxies.path')
        ];

        return $this;
    }