Skip to content

Instantly share code, notes, and snippets.

@gergoerdosi
Created May 21, 2011 22:32
Show Gist options
  • Save gergoerdosi/984961 to your computer and use it in GitHub Desktop.
Save gergoerdosi/984961 to your computer and use it in GitHub Desktop.
Patch to unset properties on state change
Index: abstract.php
--- abstract.php Base (BASE)
+++ abstract.php Locally Modified (Based On LOCAL)
@@ -107,16 +107,41 @@
*/
public function set( $property, $value = null )
{
+ $changed = false;
+
if(is_object($property)) {
$property = (array) KConfig::toData($property);
}
- if(is_array($property)) {
+ if(is_array($property))
+ {
+ foreach($property as $key => $value)
+ {
+ if(isset($this->_state->$key) && $this->_state->$key != $value)
+ {
+ $changed = true;
+ break;
+ }
+ }
+
$this->_state->setData($property);
- } else {
+ }
+ else
+ {
+ if(isset($this->_state->$property) && $this->_state->$property != $value) {
+ $changed = true;
+ }
+
$this->_state->$property = $value;
}
+ if($changed)
+ {
+ unset($this->_list);
+ unset($this->_item);
+ unset($this->_total);
+ }
+
\ No newline at end of file
return $this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment