/**
* Evaluates the attribute value and assigns it to the current attributes. If no foreignClass
* is specified, it behaves like the normal AttributeBehavior.
* @param Event $event
*/
public function evaluateAttributes($event)
{
if ($this->foreignClass === null) {
parent::evaluateAttributes($event);
} elseif (!empty($this->attributes[$event->name])) {
$fObjects = $this->getForeignObjects($this->foreignClass[0], $this->foreignClass[1]);
$attributes = (array) $this->attributes[$event->name];
$value = $this->getValue($event);
$uAttributes = [];
$n = count($fObjects);
foreach ($attributes as $attribute) {
for ($i = 0; $i < $n; ++$i) {
$fObjects[$i]->{$attribute} = $value;
}
$uAttributes[] = $attribute;
}
foreach ($fObjects as $fObject) {
$fObject->save(false, $uAttributes);
}
}
}