lithium\data\source\Database::applyStrategy PHP Method

applyStrategy() public method

Applying a strategy to a lithium\data\model\Query object
public applyStrategy ( array $options, object $context )
$options array The option array
$context object A find query object to configure
    public function applyStrategy($options, $context)
    {
        if ($context->type() !== 'read') {
            return;
        }
        $options += array('strategy' => 'joined');
        if (!($model = $context->model())) {
            throw new ConfigException('The `\'with\'` option need a valid `\'model\'` option.');
        }
        $strategy = $options['strategy'];
        if (isset($this->_strategies[$strategy])) {
            $strategy = $this->_strategies[$strategy];
            $strategy($this, $model, $context);
        } else {
            throw new QueryException("Undefined query strategy `{$strategy}`.");
        }
    }