List all config stores.

A copy of CliCache, except for further check that the cache store name
starts with 'config.'.

@see \SimpleComplex\Cache\CliCache

@return mixed
Exits if no/falsy option 'get'.
6408
protected function cmdListStores() /*: void*/
    {
        /**
         * @see simplecomplex_cache_cli()
         */
        $container = Dependency::container();
        // Validate input. ---------------------------------------------
        $match = '';
        if (
            !empty($this->command->arguments['match'])
            && ($match = trim($this->command->arguments['match'])) !== ''
            && !preg_match('/^\/.+\/[a-zA-Z]*$/', $match)
        ) {
            $this->command->inputErrors[] = '\'match\' argument must be slash delimited regular expression.';
        }

        $get = !empty($this->command->options['get']);

        if ($this->command->inputErrors) {
            foreach ($this->command->inputErrors as $msg) {
                $this->environment->echoMessage(
                    $this->environment->format($msg, 'hangingIndent'),
                    'notice'
                );
            }
            // This command's help text.
            $this->environment->echoMessage("\n" . $this->command);
            exit;
        }
        // Display command and the arg values used.---------------------
        // No arg values to list.
        // Check if the command is doable.------------------------------
        // Does that/these store(s) exist?
        if ($container->has('cache-broker')) {
            /** @var CacheBroker $cache_broker */
            $cache_broker_class = get_class($container->get('cache-broker'));
        } else {
            $cache_broker_class = static::CLASS_CACHE_BROKER;
        }
        $cache_class = constant($cache_broker_class . '::CACHE_CLASSES')[CacheBroker::CACHE_BASE];
        if (!method_exists($cache_class, 'listInstances')) {
            $this->environment->echoMessage('Cannot retrieve list of cache store instances via class['
                . $cache_class . '], has no static method listInstances().', 'error');
            exit;
        }
        $stores = forward_static_call($cache_class . '::listInstances');

        // Do it.
        $names = [];
        foreach ($stores as $instance) {
            if (preg_match('/^config\..+/', $instance->name)) {
                $name = substr($instance->name, 7);
                if (!$match || preg_match($match, $name)) {
                    $names[] = $name;
                }
            }
        }
        sort($names);
        if ($get) {
            return join(',', $names);
        }
        $this->environment->echoMessage(join("\n", $names));
        exit;
    }
1267798
public function load($configuration = false) {
        global $CFG;

        if ($configuration === false) {
            $configuration = $this->include_configuration();
        }

        $this->configstores = array();
        $this->configdefinitions = array();
        $this->configlocks = array();
        $this->configmodemappings = array();
        $this->configdefinitionmappings = array();
        $this->configlockmappings = array();

        $siteidentifier = 'unknown';
        if (array_key_exists('siteidentifier', $configuration)) {
            $siteidentifier = $configuration['siteidentifier'];
        }
        $this->siteidentifier = $siteidentifier;

        // Filter the lock instances.
        $defaultlock = null;
        foreach ($configuration['locks'] as $conf) {
            if (!is_array($conf)) {
                // Something is very wrong here.
                continue;
            }
            if (!array_key_exists('name', $conf)) {
                // Not a valid definition configuration.
                continue;
            }
            $name = $conf['name'];
            if (array_key_exists($name, $this->configlocks)) {
                debugging('Duplicate cache lock detected. This should never happen.', DEBUG_DEVELOPER);
                continue;
            }
            $conf['default'] = (!empty($conf['default']));
            if ($defaultlock === null || $conf['default']) {
                $defaultlock = $name;
            }
            $this->configlocks[$name] = $conf;
        }

        // Filter the stores.
        $availableplugins = cache_helper::early_get_cache_plugins();
        foreach ($configuration['stores'] as $store) {
            if (!is_array($store) || !array_key_exists('name', $store) || !array_key_exists('plugin', $store)) {
                // Not a valid instance configuration.
                debugging('Invalid cache store in config. Missing name or plugin.', DEBUG_DEVELOPER);
                continue;
            }
            $plugin = $store['plugin'];
            $class = 'cachestore_'.$plugin;
            $exists = array_key_exists($plugin, $availableplugins);
            if (!$exists) {
                // Not a valid plugin, or has been uninstalled, just skip it an carry on.
                debugging('Invalid cache store in config. Not an available plugin.', DEBUG_DEVELOPER);
                continue;
            }
            $file = $CFG->dirroot.'/cache/stores/'.$plugin.'/lib.php';
            if (!class_exists($class) && file_exists($file)) {
                require_once($file);
            }
            if (!class_exists($class)) {
                continue;
            }
            if (!array_key_exists('cache_store', class_parents($class))) {
                continue;
            }
            if (!array_key_exists('configuration', $store) || !is_array($store['configuration'])) {
                $store['configuration'] = array();
            }
            $store['class'] = $class;
            $store['default'] = !empty($store['default']);
            if (!array_key_exists('lock', $store) || !array_key_exists($store['lock'], $this->configlocks)) {
                $store['lock'] = $defaultlock;
            }

            $this->configstores[$store['name']] = $store;
        }

        // Filter the definitions.
        foreach ($configuration['definitions'] as $id => $conf) {
            if (!is_array($conf)) {
                // Something is very wrong here.
                continue;
            }
            if (!array_key_exists('mode', $conf) || !array_key_exists('component', $conf) || !array_key_exists('area', $conf)) {
                // Not a valid definition configuration.
                continue;
            }
            if (array_key_exists($id, $this->configdefinitions)) {
                debugging('Duplicate cache definition detected. This should never happen.', DEBUG_DEVELOPER);
                continue;
            }
            $conf['mode'] = (int)$conf['mode'];
            if ($conf['mode'] < cache_store::MODE_APPLICATION || $conf['mode'] > cache_store::MODE_REQUEST) {
                // Invalid cache mode used for the definition.
                continue;
            }
            if ($conf['mode'] === cache_store::MODE_SESSION || $conf['mode'] === cache_store::MODE_REQUEST) {
                // We force this for session and request caches.
                // They are only allowed to use the default as we don't want people changing them.
                $conf['sharingoptions'] = cache_definition::SHARING_DEFAULT;
                $conf['selectedsharingoption'] = cache_definition::SHARING_DEFAULT;
                $conf['userinputsharingkey'] = '';
            } else {
                // Default the sharing option as it was added for 2.5.
                // This can be removed sometime after 2.5 is the minimum version someone can upgrade from.
                if (!isset($conf['sharingoptions'])) {
                    $conf['sharingoptions'] = cache_definition::SHARING_DEFAULTOPTIONS;
                }
                // Default the selected sharing option as it was added for 2.5.
                // This can be removed sometime after 2.5 is the minimum version someone can upgrade from.
                if (!isset($conf['selectedsharingoption'])) {
                    $conf['selectedsharingoption'] = cache_definition::SHARING_DEFAULT;
                }
                // Default the user input sharing key as it was added for 2.5.
                // This can be removed sometime after 2.5 is the minimum version someone can upgrade from.
                if (!isset($conf['userinputsharingkey'])) {
                    $conf['userinputsharingkey'] = '';
                }
            }
            $this->configdefinitions[$id] = $conf;
        }

        // Filter the mode mappings.
        foreach ($configuration['modemappings'] as $mapping) {
            if (!is_array($mapping) || !array_key_exists('mode', $mapping) || !array_key_exists('store', $mapping)) {
                // Not a valid mapping configuration.
                debugging('A cache mode mapping entry is invalid.', DEBUG_DEVELOPER);
                continue;
            }
            if (!array_key_exists($mapping['store'], $this->configstores)) {
                // Mapped array instance doesn't exist.
                debugging('A cache mode mapping exists for a mode or store that does not exist.', DEBUG_DEVELOPER);
                continue;
            }
            $mapping['mode'] = (int)$mapping['mode'];
            if ($mapping['mode'] < 0 || $mapping['mode'] > 4) {
                // Invalid cache type used for the mapping.
                continue;
            }
            if (!array_key_exists('sort', $mapping)) {
                $mapping['sort'] = 0;
            }
            $this->configmodemappings[] = $mapping;
        }

        // Filter the definition mappings.
        foreach ($configuration['definitionmappings'] as $mapping) {
            if (!is_array($mapping) || !array_key_exists('definition', $mapping) || !array_key_exists('store', $mapping)) {
                // Not a valid mapping configuration.
                continue;
            }
            if (!array_key_exists($mapping['store'], $this->configstores)) {
                // Mapped array instance doesn't exist.
                continue;
            }
            if (!array_key_exists($mapping['definition'], $this->configdefinitions)) {
                // Mapped array instance doesn't exist.
                continue;
            }
            if (!array_key_exists('sort', $mapping)) {
                $mapping['sort'] = 0;
            }
            $this->configdefinitionmappings[] = $mapping;
        }

        usort($this->configmodemappings, array($this, 'sort_mappings'));
        usort($this->configdefinitionmappings, array($this, 'sort_mappings'));

        return true;
    }
489834
public static function get_stores_suitable_for_mode_default() {
        $factory = cache_factory::instance();
        $config = $factory->create_config_instance();
        $requirements = 0;
        foreach ($config->get_definitions() as $definition) {
            $definition = cache_definition::load($definition['component'].'/'.$definition['area'], $definition);
            $requirements = $requirements | $definition->get_requirements_bin();
        }
        $stores = array();
        foreach ($config->get_all_stores() as $name => $store) {
            if (!empty($store['features']) && ($store['features'] & $requirements)) {
                $stores[$name] = $store;
            }
        }
        return $stores;
    }
688512
public function getCacheDir()
    {
        if (is_null($this->dir)) {
            $this->dir = $this->config->cache->directory ?: sys_get_temp_dir().'/__PRAGMARX_COUNTRIES__/cache';

            if (! file_exists($this->dir)) {
                mkdir($this->dir, 0755, true);
            }
        }

        return $this->dir;
    }
630443
public function getCache()
    {
        if (!$this->cache) {
            $options = isset($this->options['cache']) ? $this->options['cache'] : [];
            foreach (static::defaultOptions()['cache'] as $k=>$v) {
                if (!isset($options[$k])) {
                    $options[$k] = $v;
                }
            }
            if (!file_exists($options['path'])) {
                $options['path'] = Config::getStoragePath() . trim($options['path'], '\\/');
            }
            
            $this->cache = new Cache($options); 
        }
        
        return $this->cache;
    }
177052
public static function getInstance()
    {
        if (self::$_instance === null) {
            self::$_instance = new Config();
            if (self::$_instance->_store === null) {
                self::$_instance->_store = self::$_instance->_setStore();
            }
        }

        return self::$_instance;
    }
52296
public function getStoreLanguageMapping() {
    $mapping = [];

    $languages = $this->languageManager->getLanguages();

    // Prepare the alternate locale data.
    foreach ($languages as $lang => $language) {
      // For default language, we access the config directly.
      if ($lang == $this->languageManager->getDefaultLanguage()->getId()) {
        $config = $this->configFactory->get('acm.store');
      }
      // We get store id from translated config for other languages.
      else {
        $config = $this->languageManager->getLanguageConfigOverride($lang, 'acm.store');
      }

      $mapping[$lang] = $config->get('store_id');
    }

    return $mapping;
  }
1218172
protected function find_file($cache = true)
	{
		if (($this->file[0] === '/' or (isset($this->file[1]) and $this->file[1] === ':')) and is_file($this->file))
		{
			$paths = array($this->file);
		}
		else
		{
			$paths = array_merge(
				\Finder::search('config/'.\Fuel::$env, $this->file, $this->ext, true, $cache),
				\Finder::search('config', $this->file, $this->ext, true, $cache)
			);
		}

		if (empty($paths))
		{
			throw new \ConfigException(sprintf('File "%s" does not exist.', $this->file));
		}

		return array_reverse($paths);
	}
1222258
public function getCache()
    {
        if (!$this->cache) {
            $this->cache = new CacheStorageHelper(
                CacheStorageHelper::ADAPTOR_DATABASE,
                'Health',
                $this->em->getConnection()
            );
        }

        return [
            'delays'     => $this->cache->get('delays'),
            'lastCached' => $this->cache->get('lastCached'),
        ];
    }
991183
protected function generate_configuration_array() {
        $configuration = array();
        $configuration['stores'] = $this->configstores;
        $configuration['modemappings'] = $this->configmodemappings;
        $configuration['definitions'] = $this->configdefinitions;
        $configuration['definitionmappings'] = $this->configdefinitionmappings;
        $configuration['locks'] = $this->configlocks;
        return $configuration;
    }
844017
protected function getConfigPaths(): array
    {
        $paths = ConfigPaths::all();

        if (count($paths) < 1) {
            WP_CLI::error_multi_line([
                'No config file found.',
                "Perhaps '" . ConfigPaths::HOOK . "' not filtering properly?",
            ]);

            WP_CLI::error('Abort!');
        }

        return $paths;
    }
541085
protected function getExcludeLocationMapIds() {
    $config = $this->configFactory->get('openy_programs_search.settings');
    $exclude_location_map = $config->get('exclude_location_map');

    return is_array($exclude_location_map) ? $exclude_location_map : [];
  }
1069843
public function getDefaultCacheStore(): ?Store
    {
        // We do not know what store is desired. Therefore,
        // the safest bet is to obtain the default
        $manager = Cache::getFacadeRoot();
        if (isset($manager)) {
            /** @var Repository $repository */
            $repository = $manager->store();
            return $repository->getStore();
        }
        return $manager;
    }
1196825
def get_stores():
    '''
    
    '''
    ret = dict()
    cmd = r"Get-ChildItem -Path 'Cert:\' | " \
          r"Select-Object LocationName, StoreNames"

    items = _cmd_run(cmd=cmd, as_json=True)

    for item in items:
        ret[item['LocationName']] = list()

        for store in item['StoreNames']:
            ret[item['LocationName']].append(store)
    return ret
12235
public function all()
	{
		if (self::$plugins !== null)
		{
			return self::$plugins;
		}

		if (!App::has('cache.store') || !($cache = App::get('cache.store')))
		{
			$cache = new \Hubzero\Cache\Storage\None();
		}

		$levels = implode(',', User::getAuthorisedViewLevels());

		if (!(self::$plugins = $cache->get('com_plugins.' . $levels)))
		{
			$db = App::get('db');

			$query = $db->getQuery()
				->select('folder', 'type')
				->select('element', 'name')
				->select('protected')
				->select('params')
				->from('#__extensions')
				->where('enabled', '>=', 1)
				->whereEquals('type', 'plugin')
				->where('state', '>=', 0)
				->whereIn('access', User::getAuthorisedViewLevels())
				->order('ordering', 'asc');

			self::$plugins = $db->setQuery($query->toString())->loadObjectList();

			if ($error = $db->getErrorMsg())
			{
				throw new Exception($error, 500);
			}

			$cache->put('com_plugins.' . $levels, self::$plugins, App::get('config')->get('cachetime', 15));
		}

		return self::$plugins;
	}
554651
private function getConfigObject()
    {
        if (!isset($this->config)) {
            $config = [];
            $file = $this->appRoot . '/' . $this->cliConfig->get('service.app_config_file');
            if (file_exists($file)) {
                $config = (array) (new YamlParser())->parseFile($file);
            }
            $this->config = new AppConfig($config);
        }

        return $this->config;
    }
272329
protected function getSettingsConfig(): array
    {
        if (!$this->cache instanceof Cache) {
            $this->items = $this->model->getSettings();
        } else {
            $cacheItems = $this->cache->get($this->cacheKey);
            if (!empty($cacheItems)) {
                $this->items = $cacheItems;
            } else {
                $this->items = $this->model->getSettings();
                $this->cache->set($this->cacheKey, $this->items);
            }
        }

        return $this->items;
    }