Get a read / write level configuration.

@param  array   $config
@param  string  $type
@return array
768757
protected function getReadWriteConfig(array $config, $type)
    {
        return isset($config[$type][0])
                        ? Arr::random($config[$type])
                        : $config[$type];
    }
805199
private function buildFallbackConfig(string $type, array $config): array
    {
        $type           = substr($type, 3);
        $fallbackConfig = $this->environment->getConfig()->get('form.layouts.' . $type, []);
        $fallbackConfig = ArrayUtil::merge($this->fallbackConfig, $fallbackConfig);

        foreach ($this->sections as $section) {
            $name = 'fallback' . ucfirst($section);

            if ($config[$name]) {
                $fallbackConfig['templates'][$section] = $config[$name];
            }
        }

        return $fallbackConfig;
    }
318368
protected function getOptionsFromConfig(Config $config)
    {
        $options = $this->options;

        if ($visibility = $config->get('visibility')) {
            // For local reference
            $options['visibility'] = $visibility;
            // For external reference
            $options['ACL'] = $visibility === AdapterInterface::VISIBILITY_PUBLIC ? 'public-read' : 'private';
        }

        if ($mimetype = $config->get('mimetype')) {
            // For local reference
            $options['mimetype'] = $mimetype;
            // For external reference
            $options['ContentType'] = $mimetype;
        }

        foreach (static::$metaOptions as $option) {
            if ( ! $config->has($option)) {
                continue;
            }
            $options[$option] = $config->get($option);
        }

        return $options;
    }
895917
public function getPluginForConfigType($config_type) {
    $plugins = [];

    foreach ($this->getDefinitions() as $plugin_id => $plugin) {
      try {
        $instance = $this->createInstance($plugin_id);
      }
      catch (PluginException $exception) {
        continue;
      }

      if ($instance->getConfigType() !== $config_type) {
        continue;
      }
      $plugins[] = [
        'plugin' => $instance,
        'weight' => $instance->weight(),
      ];
    }

    if (empty($plugins)) {
      return NULL;
    }
    usort($plugins, ['\Drupal\Component\Utility\SortArray', 'sortByWeightElement']);
    $data = reset($plugins);

    return $data['plugin'];
  }
163115
private function buildFirstDimensionOfContactsArray($type, $config)
    {
        $contacts = [];
        $websites = $this->helper->getWebsites(true);
        foreach ($websites as $website) {
            if (strpos($type, self::ORDER_STATUS_AUTOMATION) !== false) {
                $configValue = $this->helper->serializer->unserialize(
                    $this->helper->getWebsiteConfig($config, $website)
                );

                if (is_array($configValue) && !empty($configValue)) {
                    foreach ($configValue as $one) {
                        if (strpos($type, $one['status']) !== false) {
                            $contacts[$website->getId()]['programId']
                                = $one['automation'];
                        }
                    }
                }
            } else {
                $contacts[$website->getId()]['programId']
                    = $this->helper->getWebsiteConfig($config, $website);
            }
        }
        return $contacts;
    }
130344
final protected function getConfigs($config = null)
    {
        if (null !== $config) {
            if (array_key_exists($config, self::$_configs)) {
                return self::$_configs[$config];
            } else {
                return false;
            }
        }

        return self::$_configs;
    }
1090951
protected function parseConfig($config)
    {
        $parsed = [];

        foreach ($config as $key=>$value) {
            if ($value instanceof XType) {
                $parsed[$key] = $value;
                continue;
            }
            $parsed[$key] = $this->stringToType($value);
        }

        return $parsed;
    }
2056
function getConfig( $config ) {
    switch( strtoupper( $config )) {
      case 'ALLOWEMPTY':
        return $this->allowEmpty;
        break;
      case 'COMPSINFO':
        unset( $this->compix );
        $info = array();
        foreach( $this->components as $cix => $component ) {
          unset( $component->propix );
          $info[$cix]['ordno'] = $cix + 1;
          $info[$cix]['type']  = $component->objName;
          $info[$cix]['uid']   = $component->getProperty( 'uid' );
          $info[$cix]['props'] = $component->getConfig( 'propinfo' );
          $info[$cix]['sub']   = $component->getConfig( 'compsinfo' );
          unset( $component->propix );
        }
        return $info;
        break;
      case 'FORMAT':
        return $this->format;
        break;
      case 'LANGUAGE':
         // get language for calendar component as defined in [RFC 1766]
        return $this->language;
        break;
      case 'NL':
        return $this->nl;
        break;
      case 'PROPINFO':
        $output = array();
        if( 0 < count( $this->action ))
          $output['ACTION'] = count( $this->action ) / 2;
        if( 0 < count( $this->attach ))
          $output['ATTACH'] = count( $this->attach );
        if( 0 < count( $this->attendee ))
          $output['ATTENDEE'] = count( $this->attendee );
        if( 0 < count( $this->categories ))
          $output['CATEGORIES'] = count( $this->categories );
        if( 0 < count( $this->class ))
          $output['CLASS'] = count( $this->class ) / 2;
        if( 0 < count( $this->comment ))
          $output['COMMENT'] = count( $this->comment );
        if( 0 < count( $this->completed ))
          $output['COMPLETED'] = count( $this->completed ) / 2;
        if( 0 < count( $this->contact ))
          $output['CONTACT'] = count( $this->contact );
        if( 0 < count( $this->created ))
          $output['CREATED'] = count( $this->created ) / 2;
        if( 0 < count( $this->description ))
          $output['DESCRIPTION'] = count( $this->description );
        if( 0 < count( $this->dtend ))
          $output['DTEND'] = count( $this->dtend ) / 2;
        if( 0 < count( $this->dtstart ))
          $output['DTSTART'] = count( $this->dtstart ) / 2;
        if( 0 < count( $this->dtstamp ))
          $output['DTSTAMP'] = count( $this->dtstamp ) / 2;
        if( 0 < count( $this->due ))
          $output['DUE'] = count( $this->due ) / 2;
        if( 0 < count( $this->duration ))
          $output['DURATION'] = count( $this->duration ) / 2;
        if( 0 < count( $this->exdate ))
          $output['EXDATE'] = count( $this->exdate );
        if( 0 < count( $this->exrule ))
          $output['EXRULE'] = count( $this->exrule );
        if( 0 < count( $this->freebusy ))
          $output['FREEBUSY'] = count( $this->freebusy );
        if( 0 < count( $this->geo ))
          $output['GEO'] = count( $this->geo ) / 2;
        if( 0 < count( $this->lastmodified ))
          $output['LAST-MODIFIED'] = count( $this->lastmodified ) / 2;
        if( 0 < count( $this->location ))
          $output['LOCATION'] = count( $this->location ) / 2;
        if( 0 < count( $this->organizer ))
          $output['ORGANIZER'] = count( $this->organizer ) / 2;
        if( 0 < count( $this->percentcomplete ))
          $output['PERCENT-COMPLETE'] = count( $this->percentcomplete ) / 2;
        if( 0 < count( $this->priority ))
          $output['PRIORITY'] = count( $this->priority ) / 2;
        if( 0 < count( $this->rdate ))
          $output['RDATE'] = count( $this->rdate );
        if( 0 < count( $this->recurrenceid ))
          $output['RECURRENCE-ID'] = count( $this->recurrenceid ) / 2;
        if( 0 < count( $this->relatedto ))
          $output['RELATED-TO'] = count( $this->relatedto );
        if( 0 < count( $this->repeat ))
          $output['REPEAT'] = count( $this->repeat ) / 2;
        if( 0 < count( $this->requeststatus ))
          $output['REQUEST-STATUS'] = count( $this->requeststatus );
        if( 0 < count( $this->resources ))
          $output['RESOURCES'] = count( $this->resources );
        if( 0 < count( $this->sequence ))
          $output['SEQUENCE'] = count( $this->sequence ) / 2;
        if( 0 < count( $this->rrule ))
          $output['RRULE'] = count( $this->rrule );
        if( 0 < count( $this->status ))
          $output['STATUS'] = count( $this->status ) / 2;
        if( 0 < count( $this->summary ))
          $output['SUMMARY'] = count( $this->summary ) / 2;
        if( 0 < count( $this->transp ))
          $output['TRANSP'] = count( $this->transp ) / 2;
        if( 0 < count( $this->trigger ))
          $output['TRIGGER'] = count( $this->trigger ) / 2;
        if( 0 < count( $this->tzid ))
          $output['TZID'] = count( $this->tzid ) / 2;
        if( 0 < count( $this->tzname ))
          $output['TZNAME'] = count( $this->tzname );
        if( 0 < count( $this->tzoffsetfrom ))
          $output['TZOFFSETTFROM'] = count( $this->tzoffsetfrom ) / 2;
        if( 0 < count( $this->tzoffsetto ))
          $output['TZOFFSETTO'] = count( $this->tzoffsetto ) / 2;
        if( 0 < count( $this->tzurl ))
          $output['TZURL'] = count( $this->tzurl ) / 2;
        if( !in_array( $this->objName, array( 'valarm', 'vtimezone' ))) {
          if( empty( $this->uid['value'] ))
            $this->_makeuid();
          $output['UID'] = 1;
        }
        if( 0 < count( $this->url ))
          $output['URL'] = count( $this->url ) / 2;
        if( 0 < count( $this->xprop ))
          $output['X-PROP'] = count( $this->xprop );
        return $output;
        break;
      case 'UNIQUE_ID':
        if( empty( $this->unique_id ))
          $this->unique_id  = gethostbyname( $_SERVER['SERVER_NAME'] );
        return $this->unique_id;
        break;
    }
  }
963361
public static function getCache($type = '') {
        static $caches = [];

        if (!$type) {
            $loader = new ConfigurationLoader();
            $cfg    = $loader->loadConfig('cache');
            $type   = $cfg->get('default', CACHE_TYPE_REDIS);
        }
        if (!isset($caches[ $type ])) {
            if (!isset($cfg)) {
                $loader = new ConfigurationLoader();
                $cfg    = $loader->loadConfig('cache');
            }
            if (!$cfg->getb('enabled')) {
                return new Cache();
            }
            $cache = apply_filter('get_' . $type . '_cache', null, $cfg);
            if (!$cache instanceof Cache) {
                $cache = new Cache ();
            }
            $caches[ $type ] = $cache;
        }

        return $caches[ $type ];
    }
166839
static public function config($config = array())
    {
        !empty($config) && self::$config = array_merge(self::$config, $config);
        if (!empty(self::$config['cachepath'])) {
            Cache::$cachepath = self::$config['cachepath'];
        }
        if (empty(self::$config['component_verify_ticket'])) {
            self::$config['component_verify_ticket'] = Cache::get('component_verify_ticket');
        }
        if (empty(self::$config['token']) && !empty(self::$config['component_token'])) {
            self::$config['token'] = self::$config['component_token'];
        }
        if (empty(self::$config['appsecret']) && !empty(self::$config['component_appsecret'])) {
            self::$config['appsecret'] = self::$config['component_appsecret'];
        }
        if (empty(self::$config['encodingaeskey']) && !empty(self::$config['component_encodingaeskey'])) {
            self::$config['encodingaeskey'] = self::$config['component_encodingaeskey'];
        }
        return self::$config;
    }
1324108
protected function getValues( array $config )
	{
		$values = array(
			'absoluteUri' => false,
		);

		if( isset( $config['absoluteUri'] ) ) {
			$values['absoluteUri'] = (bool) $config['absoluteUri'];
		}

		return $values;
	}
177580
private function getLoaderRecipesByConfig(Config $config)
    {
        $recipes = null;
        $bundleConfig = $config->getBundleConfig();
        if (null !== $bundleConfig && isset($bundleConfig['bundle_loader_recipes'])) {
            $recipes = $bundleConfig['bundle_loader_recipes'];
        }

        return $recipes;
    }
1211509
public function getConfig($type = null)
    {
        $types = ['php' => true, 'ini' => true];
        $type  = isset($types[$type]) ? $type : 'ini';

        foreach (['app/config/', 'config/', 'apps/config/', 'apps/frontend/config/'] as $configPath) {
            if ('ini' == $type && file_exists($this->rootPath . $configPath . 'config.ini')) {
                return new ConfigIni($this->rootPath . $configPath . 'config.ini');
            } else {
                if (file_exists($this->rootPath . $configPath. 'config.php')) {
                    $config = include($this->rootPath . $configPath . 'config.php');
                    if (is_array($config)) {
                        $config = new Config($config);
                    }

                    return $config;
                }
            }
        }

        $directory = new RecursiveDirectoryIterator('.');
        $iterator = new RecursiveIteratorIterator($directory);
        foreach ($iterator as $f) {
            if (preg_match('/config\.php$/i', $f->getPathName())) {
                $config = include $f->getPathName();
                if (is_array($config)) {
                    $config = new Config($config);
                }

                return $config;
            } else {
                if (preg_match('/config\.ini$/i', $f->getPathName())) {
                    return new ConfigIni($f->getPathName());
                }
            }
        }

        throw new BuilderException("Builder can't locate the configuration file");
    }
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);
    }
1373551
protected function getConfiguredPagesFromPlugin(array $config)
    {
        // check if the tt_content row is available and if not load it manually
        // flexParentDatabaseRow not set can be caused by compatibility6 extension
        if (!isset($config['flexParentDatabaseRow']) ||
            (isset($config['flexParentDatabaseRow']) && !is_array($config['flexParentDatabaseRow']))
        ) {
            $parentRow = BackendUtility::getRecord(
                'tt_content',
                $config['row']['uid']
            );
            if (is_array($parentRow)) {
                $config['flexParentDatabaseRow'] = $parentRow;
            } else {
                // tt_content row not found
                return '';
            }
        }

        $parentRow = $config['flexParentDatabaseRow'];
        $pages = $parentRow['pages'];

        $pids = [];
        if (is_string($pages)) {
            // TYPO3 7.6
            $pagesParts = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $pages, true);
            foreach ($pagesParts as $pagePart) {
                $a = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode('|', $pagePart);
                $b = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode('_', $a[0]);
                $uid = end($b);
                $pids[] = $uid;
            }
            return implode(',', $pids);
        }

        // TYPO3 8.7
        foreach ($pages as $page) {
            $pids[] = $page['uid'];
        }
        return implode(',', $pids);
    }
381098
protected function createReadPdo(array $config)
    {
        $readConfig = $this->getReadConfig($config);

        return $this->createConnector($readConfig)->connect($readConfig);
    }
405284
private function getConfigDepth($config) {
        $total_depth = 1;

        foreach ($config as $data) {
            if (is_array($data)) {
                $depth = $this->getConfigDepth($data) + 1;

                if ($depth > $total_depth) {
                    $total_depth = $depth;
                }
            }
        }

        return $total_depth;
    }