コード例 #1
0
 /**
  * Sets a filter value for the criteria model, then reruns Live Preview filtering.
  *
  * @param string $name
  * @param mixed $value
  * @return bool
  */
 public function setAttribute($name, $value)
 {
     if (parent::setAttribute($name, $value)) {
         $method = '__' . $name;
         // Only bother setting and rerunning the filter if there exists a filtering method for it.
         if (method_exists($this, $method)) {
             $this->_currentFilters[$name] = $value;
             $this->_runCriteria();
         }
         return true;
     }
     return false;
 }
コード例 #2
0
 /**
  * Sets an attribute's value.
  *
  * In addition, will clears the cached values when a new attribute is set.
  *
  * @param string $name
  * @param mixed  $value
  *
  * @return bool
  */
 public function setAttribute($name, $value)
 {
     if (in_array($name, $this->attributeNames()) && $this->getAttribute($name) === $value) {
         return true;
     }
     if (parent::setAttribute($name, $value)) {
         $this->_matchedElements = null;
         $this->_matchedElementsAtOffsets = null;
         $this->_cachedIds = null;
         $this->_cachedTotal = null;
         return true;
     } else {
         return false;
     }
 }