Returns whether a given strategy key corresponds to a usable export strategy.

@param string $strategy
@return bool
426816
protected function isExportStrategyAvailable($strategy)
    {
        if ( ! array_key_exists($strategy, $this->getModelInformation()->export->strategies)) {
            return false;
        }

        $strategyInfo = $this->getModelInformation()->export->strategies[ $strategy ];

        $permissions = $strategyInfo->permissions();

        if (false === $permissions) {
            $permissions = [ $this->getPermissionPrefix() . 'export' ];
        }

        if (count($permissions) && ! $this->getCore()->auth()->can($permissions)) {
            return false;
        }

        return true;
    }
1056804
public function assignHavingAppliers(HavingClauseStrategy $strategy)
    {
        if ($this->havingAppliers) {
            $items = $strategy->getHaving();

            $strategy->clearHaving();

            foreach ($this->havingAppliers as $applier) {
                $clause = $this->connection()->having();

                call_user_func_array($applier, [$clause]);

                $strategy->havingConditions($clause);
            }

            if ($items) {
                $clause = $this->connection()->having();

                foreach ($items as $where) {
                    $clause->addHaving($where['logic'], $where['sql'], $where['params']);
                }

                $strategy->havingConditions($clause);
            }
        }

        return $this;
    }
143120
public function create(Strategy $strategy)
    {
        $this->getEm()->persist($strategy);
        $this->getEm()->flush();

        return $strategy;
    }
408615
protected function buildStrategyFromName($strategy, $concrete)
    {
        $concrete = $this->modulable->findQualifiedName($concrete, 'strategies', $strategy);

        if (!$concrete) {
            return false;
        }

        return new $concrete($this->container);
    }
1297481
public function isHasMany($key)
    {
        if (false === $this->isRelationship($key)) {
            return false;
        }
        return $this->getMetadata()->getRelationship($key)->isMany();
    }
30561
protected function optional($key, $default = null) {
		if (!array_key_exists($key, $this->strategy)) {
			$this->strategy[$key] = $default;
			return $default;
		}

		else return $this->strategy[$key];
	}
484927
public function fetch($strategy)
    {
        $method = 'fetch'.Inflector::classify(strtolower($strategy));

        if (!method_exists($this->association, $method)) {
            throw new InvalidArgumentException('Fetch ['.$strategy.'] does not exist');
        }

        $this->{$method}();

        return $this;
    }
458682
protected function getExportStrategyInstance($strategy)
    {
        /** @var ModelExportStrategyData $strategyData */
        $strategyData = array_get($this->getModelInformation()->export->strategies, $strategy);

        $instance = $this->getExportStrategyFactory()->make($strategyData->strategy);

        if ($strategyData) {
            $instance->setStrategyData($strategyData);
        }

        return $instance;
    }
1258536
public function setStrategy($strategy)
    {
        foreach ($this->routes as $route)
            $route->setStrategy($strategy);
        return $this;
    }
1142205
public static function decode($strategy, $value)
	{
		switch ($strategy) {
			case 'explode':
				return explode(',', $value);
			case 'json':
				return json_decode($value);
			case 'serialize':
				return unserialize($value);
		}

		return $value;
	}
645936
protected function _prepareStrategy (ModularStrategyInterface $strategy)
    {
        $this->env->makeFollower($strategy);
        
        if (!$strategy->shouldProcess()) {
            return false;
        }
        
        $strategy->prepare();
        
        return true;
    }
1025089
protected function resolveContextStrategyClass($strategy)
    {
        if ( ! empty($strategy)) {

            if ( ! str_contains($strategy, '.')) {
                $strategy = config('cms-models.strategies.repository.aliases.' . $strategy, $strategy);
            }

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

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

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

        return false;
    }
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();
        });
    }
1188843
public function has($key)
    {
        return $this->translator->has($this->composeKey($key), $this->locale);
    }
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();
        });
    }
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;
    }
220977
public function containsKey($key)
    {
        if (!$this->enabled)
            return false;

        $has_key = array_key_exists($this->key($key), $this->cache);

        // $this->Logger->debug("Cache contains {$key}? " . (($has_key) ? 'TRUE' : 'FALSE'));

        return $has_key;
    }