Resolves strategy assuming it is the class name or FQN of a show field interface
implementation or an alias for one.

@param string $strategy
@return string|false     returns full class namespace if it was resolved succesfully
194058
protected function resolveStrategyClass($strategy)
    {
        if (    ! str_contains($strategy, '.')
            &&  $aliasStrategy = config(
                'cms-models.strategies.show.aliases.' . $strategy,
                config('cms-models.strategies.list.aliases.' . $strategy)
            )
        ) {
            $strategy = $aliasStrategy;
        }

        if (class_exists($strategy) && is_a($strategy, ShowFieldInterface::class, true)) {
            return $strategy;
        }

        $strategy = $this->prefixStrategyNamespace($strategy);

        if (class_exists($strategy) && is_a($strategy, ShowFieldInterface::class, true)) {
            return $strategy;
        }

        return false;
    }
534332
protected function resolveAlias($alias)
	{
		if (!empty($this->aliases[$alias]))
		{
			return $this->aliases[$alias];
		}

		return $alias;
	}
503016
public function register($name, AuthStrategy $strategy)
    {
        if($this->getOrNull($name)) {
            throw new StrategyAlreadyRegisteredException;
        };

        $this->strategies[$name] = $strategy;

        return $this;
    }
29243
public function get()
    {
        foreach ($this->_strategies as $strategy) {
            $result = $strategy->get();
            if ($result !== null) {
                return $result;
            }
        }

        return null;
    }
4091
public function strategy(string $strategy, array $options = []): ListFilter
    {
        $this->main['strategy'] = $strategy;

        if (count($options)) {
            $this->main['options'] = $options;
        }

        return $this;
    }
1321498
protected function getCommand(StrategyInterface $strategy)
    {
        $command = $strategy->get();
        if ($command === null) {
            throw new Exception('Failed to locate a sensible command');
        }

        return $command;
    }
1113106
protected function get_strategy_handler($strategy) {
        global $CFG; // we include other files here

        if (is_null($this->strategyhandlers)) {
            $this->strategyhandlers = array();
            $subplugins = core_component::get_plugin_list('workshopform');
            foreach ($subplugins as $name => $dir) {
                $handlerfile  = $dir.'/backup/moodle1/lib.php';
                $handlerclass = "moodle1_workshopform_{$name}_handler";
                if (!file_exists($handlerfile)) {
                    continue;
                }
                require_once($handlerfile);

                if (!class_exists($handlerclass)) {
                    throw new moodle1_convert_exception('missing_handler_class', $handlerclass);
                }
                $this->log('preparing workshop grading strategy handler', backup::LOG_DEBUG, $handlerclass);
                $this->strategyhandlers[$name] = new $handlerclass($this, $name);
                if (!$this->strategyhandlers[$name] instanceof moodle1_workshopform_handler) {
                    throw new moodle1_convert_exception('wrong_handler_class', get_class($this->strategyhandlers[$name]));
                }
            }
        }

        if (!isset($this->strategyhandlers[$strategy])) {
            throw new moodle1_convert_exception('usupported_subplugin', 'workshopform_'.$strategy);
        }

        return $this->strategyhandlers[$strategy];
    }
1190939
protected function resolveFieldDescription($prop): ?string
    {
        /** @var Annotation\Field $annotation */
        if ($annotation = $this->getFieldAnnotation($prop, Annotation\Field::class)) {
            return $annotation->description;
        }

        return null;
    }
717168
public function getStrategy($name)
    {
        if (isset($this->strategies[$name])) {
            return $this->strategies[$name];
        }

        if (!isset($this->strategies['*'])) {
            throw new Exception\InvalidArgumentException(sprintf(
                '%s: no strategy by name of "%s", and no wildcard strategy present',
                __METHOD__,
                $name
            ));
        }

        return $this->strategies['*'];
    }
712961
public function resolveClassAlias($alias)
    {
        $alias = static::normalise($alias);

        if (isset($this->classAliases[$alias])) {
            return $this->classAliases[$alias];
        }

        return $alias;
    }
83868
public function resolve($alias)
	{
		// Check wether the alias matches the pattern
		if ( ! preg_match($this->regex, $alias, $matches))
		{
			return false;
		}

		// Get the translation
		$translation = $this->translation;

		if (strpos($translation, '$') === false)
		{
			$class = $translation;
		}
		else
		{
			// Make sure namespace seperators are escaped
			$translation = str_replace('\\', '\\\\', $translation);

			// Resolve the replacement
			$class = preg_replace($this->regex, $translation, $alias);
		}

		// Check wether the class exists
		if ($class and $this->objectExists($class, true))
		{
			return $class;
		}

		return false;
	}
1258536
public function setStrategy($strategy)
    {
        foreach ($this->routes as $route)
            $route->setStrategy($strategy);
        return $this;
    }
412607
protected function resolveOptionsAlias(array $options)
	{
		$haystack = array_diff_key($options, $this->getAliasOptions() + ['output' => null]);
		
		foreach ($this->getAliasOptions() as $option => $value)
		{
			if (isset($options[$option]))
			{
				$haystack[$value] = $options[$option];
				
				if (is_bool($options[$option]))
				{
					$haystack[$value] = '';
				}
			}
		}
		
		return $haystack;
	}
996666
public function resolve(string $alias) : bool
    {
        // return false if alias already resolved.
        if (in_array($alias, $this->resolved)) {
            return false;
        }

        $this->resolved[] = $alias;

        // Resolve class alias if set.
        if ($this->has($alias)) {
            $class = $this->get($alias);
            $class = (class_exists($class, true)) ? $class : false;
        } else {
            // Resolve namespace alias.
            $class = $this->resolveNamespaceAlias($alias);
        }

        // Remove the resolved class
        array_pop($this->resolved);

        // If class exists create and return a alias of the class.
        return (!class_exists($class)) ? false : class_alias($class, $alias);
    }
871140
public function make($strategy)
    {
        if ( ! $strategy) {
            return $this->getDefaultStrategy();
        }

        // If the strategy indicates the FQN of display strategy,
        // or a classname that can be found in the default strategy name path, use it.
        if ($strategyClass = $this->resolveStrategyClass($strategy)) {

            return app($strategyClass);
        }

        throw new RuntimeException("Could not create strategy instance for '{$strategy}'");
    }
29732
protected function buildStrategies()
    {
        foreach ($this->strategies as $parameterName => &$strategy) {

            // only build strategies we will actually use

            if ($this->isParameterIgnored($parameterName)) continue;

            // get the value for the filter parameter
            // and if it is empty, we're not filtering by it and should skip it
            $parameterValue = $this->parameterValue($parameterName);

            if ($this->isParameterValueUnset($parameterName, $parameterValue)) continue;

            // check if the strategy is a string that should be instantiated as a class
            if (is_string($strategy) && $strategy !== static::SETTING) {

                try {

                    $reflection = new ReflectionClass($strategy);

                    if ( ! $reflection->IsInstantiable()) {
                        throw new ParameterStrategyInvalidException("Uninstantiable string provided as strategy for '{$strategy}'");
                    }

                    $strategy = new $strategy();

                } catch (\Exception $e) {

                    throw new ParameterStrategyInvalidException(
                        "Exception thrown while trying to reflect or instantiate string provided as strategy for '{$strategy}'",
                        0, $e
                    );
                }

                // check if it is of the correct type
                if ( ! is_a($strategy, ParameterFilterInterface::class)) {

                    throw new ParameterStrategyInvalidException(
                        "Instantiated string provided is not a ParameterFilter: '" . get_class($strategy) . "'"
                    );
                }
            }
        }

        unset($strategy);

        return $this->strategies;
    }
1244680
public function executeStrategyMethod($strategy, $method)
    {
        $strategy = $this->getStrategy($strategy);
        if (!$strategy) {
            return true;
        }

        return $this->explainer->displayBelow(function () use ($strategy, $method) {
            return $strategy->$method();
        });
    }