Adds the specific strategy of error handling.

@param \Es\Error\Strategy\AbstractErrorStrategy $strategy The strategy
772977
public function attachErrorStrategy(AbstractErrorStrategy $strategy)
    {
        if ($strategy instanceof HtmlErrorStrategy) {
            $this->setDefaultErrorStrategy($strategy);

            return;
        }
        $this->strategies->attach($strategy);
    }
293107
public function assignOffsetAppliers(OffsetClauseStrategy $strategy)
    {
        if ($this->offsetAppliers and !$strategy->hasOffset()) {
            foreach ($this->offsetAppliers as $applier) {
                $clause = $this->connection()->offset();

                call_user_func_array($applier, [$clause]);

                $strategy->offset($clause->getOffset());
            }
        }

        return $this;
    }
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;
    }
1192561
public MockInjectionStrategy thenTry(MockInjectionStrategy strategy) {
        if(nextStrategy != null) {
            nextStrategy.thenTry(strategy);
        } else {
            nextStrategy = strategy;
        }
        return strategy;
    }
1209483
public function setErrorType($error)
    {
        if (isset($this->errorTypes[$error])) {
            $this->message = trim($this->errorTypes[$error].': '.$this->message);
        }
    }
93376
public function export($strategy)
    {
        // Check if the strategy is available and allowed to be used
        if ( ! $this->isExportStrategyAvailable($strategy)) {
            abort(403, "Not possible or allowed to perform export '{$strategy}'");
        }

        // Prepare the strategy instance
        $exporter = $this->getExportStrategyInstance($strategy);
        $filename = $this->getExportDownloadFilename($strategy, $exporter->extension());

        $this->checkListParents()
             ->checkActiveSort(false)
             ->checkScope(false)
             ->checkFilters()
             ->checkActivePage(false)
             ->applySort()
             ->applyScope($this->modelRepository);

        $query = $this->getModelRepository()->query();

        $this->applyFilter($query)
             ->applyListParentToQuery($query);

        $download = $exporter->download($query, $filename);

        if (false === $download) {
            // @codeCoverageIgnoreStart
            abort(500, "Failed to export model listing for strategy '{$strategy}'");
            // @codeCoverageIgnoreEnd
        }

        event( new Events\ModelListExportedInCms($this->modelInformation->modelClass(), $strategy) );

        return $download;
    }
1133084
public function registerStrategy($name, ConnectionStrategy $strategy, bool $default = false)
    {
        $this->connections[$name] = $strategy;

        if ($default) {
            $this->setDefaultConnectionName($name);
        }

        return $this;
    }
1185001
public function optimisticLocking(IOptimisticLockingStrategy $strategy)
    {
        foreach ($strategy->getLockingColumnNames() as $columnName) {
            if (!isset($this->columns[$columnName])) {
                throw InvalidArgumentException::format(
                    'Cannot add optimistic locking strategy: expecting one of columns (%s), \'%s\' given',
                    Debug::formatValues(array_keys($this->columns)), $columnName
                );
            }
        }

        $this->lockingStrategies[] = $strategy;
    }
1304899
protected function applyFilterStrategyToQuery($query, $target, $value, $strategy = null)
    {
        if (null === $strategy) {
            $strategy = config('cms-models.meta-references.filter-strategy');
        }

        $filter = $this->getFilterFactory()->make($strategy);

        $filter->apply($query, $target, $value);
    }
632775
public static function usesSet(string $strategy) : bool
    {
        return in_array(
            $strategy,
            [
                ClassMetadata::STORAGE_STRATEGY_SET,
                ClassMetadata::STORAGE_STRATEGY_SET_ARRAY,
                ClassMetadata::STORAGE_STRATEGY_ATOMIC_SET,
                ClassMetadata::STORAGE_STRATEGY_ATOMIC_SET_ARRAY,
            ]
        );
    }
302282
public static function isAtomic(string $strategy) : bool
    {
        return $strategy === ClassMetadata::STORAGE_STRATEGY_ATOMIC_SET || $strategy === ClassMetadata::STORAGE_STRATEGY_ATOMIC_SET_ARRAY;
    }
854564
protected function addWhereByStrategy(string $strategy, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $alias, string $field, $value, bool $caseSensitive)
    {
        $wrapCase = $this->createWrapCase($caseSensitive);
        $valueParameter = $queryNameGenerator->generateParameterName($field);

        switch ($strategy) {
            case null:
            case self::STRATEGY_EXACT:
                $queryBuilder
                    ->andWhere(sprintf($wrapCase('%s.%s').' = '.$wrapCase(':%s'), $alias, $field, $valueParameter))
                    ->setParameter($valueParameter, $value);
                break;
            case self::STRATEGY_PARTIAL:
                $queryBuilder
                    ->andWhere(sprintf($wrapCase('%s.%s').' LIKE '.$wrapCase('CONCAT(\'%%\', :%s, \'%%\')'), $alias, $field, $valueParameter))
                    ->setParameter($valueParameter, $value);
                break;
            case self::STRATEGY_START:
                $queryBuilder
                    ->andWhere(sprintf($wrapCase('%s.%s').' LIKE '.$wrapCase('CONCAT(:%s, \'%%\')'), $alias, $field, $valueParameter))
                    ->setParameter($valueParameter, $value);
                break;
            case self::STRATEGY_END:
                $queryBuilder
                    ->andWhere(sprintf($wrapCase('%s.%s').' LIKE '.$wrapCase('CONCAT(\'%%\', :%s)'), $alias, $field, $valueParameter))
                    ->setParameter($valueParameter, $value);
                break;
            case self::STRATEGY_WORD_START:
                $queryBuilder
                    ->andWhere(sprintf($wrapCase('%1$s.%2$s').' LIKE '.$wrapCase('CONCAT(:%3$s, \'%%\')').' OR '.$wrapCase('%1$s.%2$s').' LIKE '.$wrapCase('CONCAT(\'%% \', :%3$s, \'%%\')'), $alias, $field, $valueParameter))
                    ->setParameter($valueParameter, $value);
                break;
            default:
                throw new InvalidArgumentException(sprintf('strategy %s does not exist.', $strategy));
        }
    }
21455
private void setStrategy(final ClassRealm realm, final Strategy strategy) {
        assert realm != null;
        assert strategy != null;

        try {
            Field field = realm.getClass().getDeclaredField("strategy");

            try {
                field.set(realm, strategy);
            }
            catch (IllegalAccessException ignore) {
                // try again
                field.setAccessible(true);

                try {
                    field.set(realm, strategy);
                }
                catch (IllegalAccessException e) {
                    throw new IllegalAccessError(e.getMessage());
                }
            }
        }
        catch (NoSuchFieldException e) {
            throw new Error(e);
        }
    }
828727
public function deleteConditionStrategy(string $strategy, array $parameters = []): Model
    {
        if ( ! array_has($this->main, 'delete_condition')) {
            $this->main['delete_condition'] = '';
        }

        $this->main['delete_condition'] .= ($this->main['delete_condition'] ? '|' : '') . $strategy;

        if (count($parameters)) {

            $serializedParameters = implode(
                ',',
                array_map(
                    function ($value) {
                        return (string) $value;
                    },
                    $parameters
                )
            );

            $this->main['delete_condition'] .= ':' . $serializedParameters;
        }

        return $this;
    }
645936
protected function _prepareStrategy (ModularStrategyInterface $strategy)
    {
        $this->env->makeFollower($strategy);
        
        if (!$strategy->shouldProcess()) {
            return false;
        }
        
        $strategy->prepare();
        
        return true;
    }
711010
public function getStrategy($strategy, $concrete = null, $options = [])
    {
        // Try to build the strategy
        $strategy = $this->builder->buildStrategy($strategy, $concrete);
        if (!$strategy || !$strategy->isExecutable()) {
            return;
        }

        // Configure strategy
        if ($options || $this->options) {
            $options = array_replace((array) $options, $strategy->getOptions(), $this->options);
            $strategy = $strategy->setOptions($options);
        }

        return $this->explainer->displayBelow(function () use ($strategy) {
            return $strategy->displayStatus();
        });
    }
1051454
private function deserializeStrategy($strategy)
    {
        switch ($strategy) {
            case 'affirmative':
                return Toggle::STRATEGY_AFFIRMATIVE;
            case 'majority':
                return Toggle::STRATEGY_MAJORITY;
            case 'unanimous':
                return Toggle::STRATEGY_UNANIMOUS;
        }

        throw new RuntimeException(sprintf('Unknown toggle strategy "%s".', $strategy));
    }