Created
February 2, 2012 19:18
-
-
Save mattlanham/1725205 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 | |
namespace Orm; | |
class Observer_Accountid extends Observer | |
{ | |
/** | |
* @var string property to set the timestamp on | |
*/ | |
public static $property = 'account_id'; | |
protected $_property; | |
public function __construct($class) | |
{ | |
$props = $class::observers(get_class($this)); | |
$this->_property = isset($props['property']) ? $props['property'] : static::$property; | |
} | |
public function before_insert(Model $model) | |
{ | |
if(!$model->account_id) $model->{$this->_property} = \Session::get('account_id', \Inquirely::get_account()->id); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment