Created
August 26, 2011 19:27
-
-
Save kiall/1174212 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ORM extends Kohana_ORM { | |
public function create(Validation $validation = NULL) | |
{ | |
$this->_pre_create(); | |
$return = parent::create($validation); | |
// Get any default values from the DB.. | |
$this->reload(); | |
$this->_post_create(); | |
return $return; | |
} | |
protected function _pre_create() | |
{ | |
$stomp = Stomp::instance(); | |
$stomp->send($this->as_array(), '/topic/orm.create.pre.'.$this->_object_name); | |
} | |
protected function _post_create() | |
{ | |
$stomp = Stomp::instance(); | |
$stomp->send($this->as_array(), '/topic/orm.create.post.'.$this->_object_name); | |
} | |
public function update(Validation $validation = NULL) | |
{ | |
$changed = $this->changed(); | |
$this->_pre_update($changed); | |
$return = parent::update($validation); | |
$this->_post_update($changed); | |
return $return; | |
} | |
protected function _pre_update($changed) | |
{ | |
$stomp = Stomp::instance(); | |
$stomp->send($this->as_array(), '/topic/orm.update.pre.'.$this->_object_name); | |
} | |
protected function _post_update($changed) | |
{ | |
$stomp = Stomp::instance(); | |
$stomp->send($this->as_array(), '/topic/orm.update.post.'.$this->_object_name); | |
} | |
public function delete() | |
{ | |
$original = clone $this; | |
$this->_pre_delete($original); | |
$return = parent::delete(); | |
$this->_post_delete($original); | |
return $return; | |
} | |
protected function _pre_delete() | |
{ | |
$stomp = Stomp::instance(); | |
$stomp->send($this->as_array(), '/topic/orm.delete.pre.'.$this->_object_name); | |
} | |
protected function _post_delete($original) | |
{ | |
$stomp = Stomp::instance(); | |
$stomp->send($original->as_array(), '/topic/orm.delete.post.'.$this->_object_name); | |
} | |
public function add($alias, $far_keys) | |
{ | |
$this->_pre_add($alias, $far_keys); | |
$return = parent::add($alias, $far_keys); | |
$this->_post_add($alias, $far_keys); | |
return $return; | |
} | |
protected function _pre_add($alias, $far_keys) | |
{ | |
$stomp = Stomp::instance(); | |
$stomp->send($this->as_array(), '/topic/orm.add.pre.'.$this->_object_name.'.'.$alias); | |
} | |
protected function _post_add($alias, $far_keys) | |
{ | |
$stomp = Stomp::instance(); | |
$stomp->send($this->as_array(), '/topic/orm.add.post.'.$this->_object_name.'.'.$alias); | |
} | |
public function remove($alias, $far_keys = NULL) | |
{ | |
$this->_pre_remove($alias, $far_keys); | |
$return = parent::remove($alias, $far_keys); | |
$this->_post_remove($alias, $far_keys); | |
return $return; | |
} | |
protected function _pre_remove($alias, $far_keys) | |
{ | |
$stomp = Stomp::instance(); | |
$stomp->send($this->as_array(), '/topic/orm.remove.pre.'.$this->_object_name.'.'.$alias); | |
} | |
protected function _post_remove($alias, $far_keys) | |
{ | |
$stomp = Stomp::instance(); | |
$stomp->send($this->as_array(), '/topic/orm.remove.post.'.$this->_object_name.'.'.$alias); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment