Commit 55daae47 by Qiang Xue

Fixes issue #589: validate the scenario name.

parent 3a365dae
...@@ -583,10 +583,15 @@ class Model extends Component implements \IteratorAggregate, \ArrayAccess ...@@ -583,10 +583,15 @@ class Model extends Component implements \IteratorAggregate, \ArrayAccess
/** /**
* Sets the scenario for the model. * Sets the scenario for the model.
* @param string $value the scenario that this model is in. * @param string $value the scenario that this model is in.
* @see getScenario * @throws InvalidParamException if the scenario to be set is unknown
* @see scenarios()
*/ */
public function setScenario($value) public function setScenario($value)
{ {
$scenarios = $this->scenarios();
if (!isset($scenarios[$value])) {
throw new InvalidParamException("Setting unknown scenario: $value");
}
$this->_scenario = $value; $this->_scenario = $value;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment