Beispiel #1
0
 /**
  * Sets the value in the $data array after calling coerce() on the value.
  *
  * @param string $attributeName
  * @param mixed $value
  * @return Record Returns itself for chaining.
  */
 public function set($attributeName, $value)
 {
     if (!array_key_exists($attributeName, $this->dao->getAttributes())) {
         $this->triggerUndefinedAttributeError($attributeName);
         return $this;
     }
     $value = $this->dao->coerce($attributeName, $value, $this->getAttributeType($attributeName), in_array($attributeName, $this->dao->getNullAttributes()));
     $this->data[$attributeName] = $value;
     $this->changedAttributes[$attributeName] = true;
     // If there is a cache dependency for this attribute, clear the cache related to it.
     if (isset($this->cacheDependencies[$attributeName])) {
         $dependencies = $this->cacheDependencies[$attributeName];
         if (is_array($dependencies)) {
             foreach ($dependencies as $dependency) {
                 $this->clearComputedAttributesCache($dependency);
             }
         } else {
             $this->clearComputedAttributesCache($dependencies);
         }
     }
     return $this;
 }