Fetch and validate the keyfile and set the project ID.

@param  array $config
@return array
329565
private function configureAuthentication(array $config)
    {
        $config['keyFile'] = $this->getKeyFile($config);
        $this->projectId = $this->detectProjectId($config);

        return $config;
    }
441343
public function loadConfig($config = null)
    {
        $config =
            !is_null($config) || !file_exists($this->configFile)
                ? $this->setConfigFile($this->getConfigFile($config))
                : $this->configFile;

        return $this->loadToLaravelConfig($config);
    }
438867
public function connect(Array $config)
    {
        $dsn = $this->getDSN($config);
        $options = $this->getOptions($config);

        $connection = $this->createConnection($dsn, $config, $options);

        if (isset($config['charset'])) {
            $connection->prepare("set names '" . $config['charset'] . "'")->execute();
        }

        if (isset($config['timezone'])) {
            $connection->prepare("set time zone '" . $config['timezone'] . "'")->execute();
        }

        return $connection;
    }
1313332
final public function get(array $appConfig): array
    {
        assert($appConfig !== null);

        $defaults = $this->getSettings();

        $eventsFolder = $defaults[static::KEY_EVENTS_FOLDER] ?? null;
        assert(
            $eventsFolder !== null && empty(glob($eventsFolder)) === false,
            "Invalid Events folder `$eventsFolder`."
        );

        $eventsFileMask = $defaults[static::KEY_EVENTS_FILE_MASK] ?? null;
        assert(empty($eventsFileMask) === false, "Invalid Events file mask `$eventsFileMask`.");

        $subscribersFolder = $defaults[static::KEY_SUBSCRIBERS_FOLDER] ?? null;
        assert(
            $subscribersFolder !== null && empty(glob($subscribersFolder)) === false,
            "Invalid Subscribers folder `$subscribersFolder`."
        );

        $subscribersFileMask = $defaults[static::KEY_SUBSCRIBERS_FILE_MASK] ?? null;
        assert(empty($subscribersFileMask) === false, "Invalid Subscribers file mask `$subscribersFileMask`.");

        $eventsPath      = $eventsFolder . DIRECTORY_SEPARATOR . $eventsFileMask;
        $subscribersPath = $subscribersFolder . DIRECTORY_SEPARATOR . $subscribersFileMask;

        $emitter      = new SimpleEventEmitter();
        /** @noinspection PhpParamsInspection */
        $eventClasses = iterator_to_array(
            $this->selectClasses($eventsPath, EventInterface::class)
        );
        /** @noinspection PhpParamsInspection */
        $handlerClasses = iterator_to_array(
            $this->selectClasses($subscribersPath, EventHandlerInterface::class)
        );

        $allowedEvents = $this->getParentEvents($eventClasses);
        $emitter->addAllowedEvents($allowedEvents);

        foreach ($this->getEventSubscribers($eventClasses, $handlerClasses) as $eventClass => $subscriber) {
            $emitter->subscribe($eventClass, $subscriber);
        }

        $cacheData = $emitter->getData();

        return $defaults + [static::KEY_CACHED_DATA => $cacheData];
    }
93593
protected function getConfigData($config)
    {
        if (is_string($config)) {
            if (!file_exists($config)) {
                throw new \InvalidArgumentException("Config file $config not found");
            }
            $this->loadConfigFile($config);
        } elseif (is_array($config)) {
            $this->loadFromHash($config);
        }

        $this->loadConfigFile('iron.ini');
        $this->loadConfigFile('iron.json');

        $this->loadFromEnv(strtoupper($this->product_name));
        $this->loadFromEnv('IRON');

        if (!ini_get('open_basedir')) {
            $this->loadConfigFile(self::homeDir() . '.iron.ini');
            $this->loadConfigFile(self::homeDir() . '.iron.json');
        }

        $this->loadFromHash($this->default_values);

        if (empty($this->token) || empty($this->project_id)) {
            throw new \InvalidArgumentException("token or project_id not found in any of the available sources");
        }
    }
151050
public static function configure(array $config)
    {
        static::$config = $config;

        if (is_null(static::$mounted)) {
            static::$mounted = static::mount($config['disk']['mount']);
        }

        return static::$mounted;
    }
151246
private function validate(array $config = [])
    {
        $customfields = [];
        foreach ($config as $classname => $customfield) {
            if (!class_exists($classname)) {
                continue;
            }
            array_push($customfields, $customfield);
        }
        return !empty($customfields);
    }
129434
protected function getConfig(array $config): array
    {
        $keys = [
            'auth_key',
            'secret',
            'app_id',
            'options',
            'host',
            'port',
            'timeout',
        ];

        foreach ($keys as $key) {
            if (!array_key_exists($key, $config)) {
                throw new InvalidArgumentException("Missing configuration key [$key].");
            }
        }

        foreach ($config['options'] as $option => $value) {
            if (is_null($value)) {
                unset($config['options'][$option]);
            }
        }

        return array_only($config, $keys);
    }
1233248
protected function getConfig(array $config)
    {
        if (!array_key_exists('prefix', $config)) {
            $config['prefix'] = null;
        }

        if (!array_key_exists('bucket', $config)) {
            throw new InvalidArgumentException('The awss3 connector requires bucket configuration.');
        }

        return array_only($config, ['bucket', 'prefix']);
    }
1017158
public function validator($config = array())
    {
        $config = new ObjectConfigJson($config);
        $config->append(array(
            'debug'    => \Kodekit::getInstance()->isDebug(),
            'selector' => '.k-js-form-controller',
            'options_callback' => null,
            'options'  => array(
                'ignoreTitle' => true,
                'onsubmit'    => false // We run the validation ourselves
            )
        ));

        $html = '';

        if(!static::isLoaded('validator'))
        {
            $html .= $this->kodekit();
            $html .= '<ktml:script src="assets://js/'.($config->debug ? 'build/' : 'min/').'jquery.validate.js" />';

            static::setLoaded('validator');
        }

        $options   = (string) $config->options;
        $signature = md5('validator-'.$config->selector.$config->options_callback.$options);

        if (!static::isLoaded($signature))
        {
            if ($config->options_callback) {
                $options = $config->options_callback.'('.$options.')';
            }

            $html .= "<script>
            kQuery(function($){
                $('$config->selector').on('k:validate', function(event){
                    if(!$(this).valid() || $(this).validate().pendingRequest !== 0) {
                        event.preventDefault();
                    }
                }).validate($options);
            });
            </script>";

            static::setLoaded($signature);
        }

        return $html;
    }
1264784
private function createClient($config)
    {
        $keyFile = array_get($config, 'key_file');
        if (is_string($keyFile)) {
            return new StorageClient([
                'projectId' => $config['project_id'],
                'keyFilePath' => $keyFile,
            ]);
        }

        if (! is_array($keyFile)) {
            $keyFile = [];
        }
        return new StorageClient([
            'projectId' => $config['project_id'],
            'keyFile' => array_merge(["project_id" => $config['project_id']], $keyFile)
        ]);
    }
274787
public function connect(array $config)
    {
        $ironConfig = array('token' => $config['token'], 'project_id' => $config['project']);

        if (isset($config['host'])) $ironConfig['host'] = $config['host'];

        $iron = new IronMQ($ironConfig);

        if (isset($config['ssl_verifypeer']))
        {
            $iron->ssl_verifypeer = $config['ssl_verifypeer'];
        }

        return new IronQueue($iron, $this->request, $config['queue'], $config['encrypt']);
    }
117558
public static function get(array $config)
    {
        if (!isset($config['driver']) || !$config['driver']) {
            throw new \RuntimeException('no driver specified');
        }

        $driver = strtolower($config['driver']);

        if (!in_array($driver, array('sqlite', 'mysql', 'sqlserver', 'postgre'), true)) {
            throw new \UnexpectedValueException('PDO driver "' . $driver . '" not supported by PIMF');
        }

        if (!extension_loaded('pdo') || !extension_loaded('pdo_' . $driver)) {
            throw new \RuntimeException('Please navigate to "http://php.net/manual/pdo.installation.php" '
                . ' to find out how to install "PDO" with "pdo_' . $driver . '" on your system!');
        }

        $driver = '\Pimf\Pdo\\' . ucfirst($driver);

        $pdo = new $driver();

        return $pdo->connect($config);
    }
456427
public static function buildConfig($config = array())
    {
        $default = static::getDefaultParameters();
        $required = static::getRequiredParameters();
        $config = Collection::fromConfig($config, $default, $required);

        $standardHeaders = array(
            'Accept-Charset' => 'utf-8',
            'Accept'         => 'application/json',
        );

        $requestOptions = array(
            'headers' => $standardHeaders,
        );

        $config->add('request.options', $requestOptions);

        return $config;
    }
809673
protected function formatS3Config(array $config)
    {
        $config += ['version' => 'latest'];
        if ($config['key'] && $config['secret']) {
            $config['credentials'] = ArrayHelper::only($config, ['key', 'secret']);
        }
        return $config;
    }
1051650
public function process(array $data, array $config)
	{
		// Intersect the data given the with the data keys provided.
		$specifiedData = array_intersect_key($data, array_flip(array_keys($config)));

		// Unset password if null, otherwise hash it for saving.
		if(array_key_exists('password', $specifiedData))
		{
			// Unset password rules if null.
			if(is_null($specifiedData['password']))
			{
				unset($rules['password']);
			}
		}

		// Validate and set our errors if they exist.
		$this->errorPayload = $this->validator->validate($specifiedData, $config);

		// Return sanitized data if no validation errors exist.
		if($this->errorPayload->getStatus() == Payload::STATUS_VALID)
		{
			// Hash password if present.
			if(array_key_exists('password', $specifiedData))
			{
				$specifiedData['password'] = Hash::make($specifiedData['password']);
			}

			return new Payload($specifiedData, Payload::STATUS_VALID);
		}

		return $this->errorPayload;
	}
893429
public function setAppRoot(array $config)
    {
        $this->app_name   = $config['app_name'];
        $this->app_dir    = rtrim($config['app_dir'], '/');
        $this->debug      = $config['debug'];
        $this->config_dir = $config['config_dir'];
        $this->view_dir   = $config['view_dir'];
        $this->vars_dir   = $config['vars_dir'];
        return $this;
    }