using the ZF quickstart create model, as a basis for this topic.
I would like to understand exactly what the __construct and the setOptions() method are supposed to be doing in this context.
No matter how many times I bang on it, I'm just no getting what these two methods are doing.
public function __construct(array $options = null)
{
//if it is an array of options the call setOptions and apply those options
//so what? What Options
if (is_array($options)) {
$this->setOptions($options);
}
}
public function setOptions(array $options)
{
//I can see this starts by getting all the class methods and return array()
$methods = get_class_methods($this);
//loop through the options and assign them to $method as setters?
foreach ($options as $key => $value) {
$method = 'set' . ucfirst($key);
if (in_array($method, $methods)) {
$this->$method($value);
}
}
return $this;
}
I really get lost on the setOptons(), I can't figure out what it's trying to accomplish. I understand it's abstracting some behavior, I just can't quite fathom what.
So far as I can tell, this is just so much 'so what!'. I would like to understand it as it might prove important.