lithium\data\source\Database::applyStrategy()

public method

Applying a strategy to a lithium\data\model\Query object

Parameters

  • array $options

    The option array

  • object $context

    A find query object to configure

Source

	public function applyStrategy($options, $context) {
		if ($context->type() !== 'read') {
			return;
		}

		$options += ['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($model, $context);
		} else {
			throw new QueryException("Undefined query strategy `{$strategy}`.");
		}
	}