From: Andrey Kutejko Date: Mon, 15 Jul 2013 18:27:04 +0000 (+0300) Subject: exclude timestampable's fields by default X-Git-Tag: 0.5~167 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=13b3a7634fe0d8d0f11156abe49cf7f2a78d6f3e;p=ipf.git exclude timestampable's fields by default --- diff --git a/ipf/orm/template/timestampable.php b/ipf/orm/template/timestampable.php index 9a5b9e7..7c0c1fb 100644 --- a/ipf/orm/template/timestampable.php +++ b/ipf/orm/template/timestampable.php @@ -1,19 +1,27 @@ array('name' => 'created_at', - 'type' => 'timestamp', - 'format' => 'Y-m-d H:i:s', - 'disabled' => false, - 'expression' => false, - 'options' => array()), - 'updated' => array('name' => 'updated_at', - 'type' => 'timestamp', - 'format' => 'Y-m-d H:i:s', - 'disabled' => false, - 'expression' => false, - 'onInsert' => true, - 'options' => array())); +class IPF_ORM_Template_Timestampable extends IPF_ORM_Template +{ + protected $_options = array( + 'created' => array( + 'name' => 'created_at', + 'type' => 'timestamp', + 'format' => 'Y-m-d H:i:s', + 'disabled' => false, + 'expression' => false, + 'options' => array('exclude' => true), + ), + 'updated' => array( + 'name' => 'updated_at', + 'type' => 'timestamp', + 'format' => 'Y-m-d H:i:s', + 'disabled' => false, + 'expression' => false, + 'onInsert' => true, + 'exclude' => true, + 'options' => array('exclude' => true), + ), + ); public function __construct(array $options = array()) { @@ -22,12 +30,13 @@ class IPF_ORM_Template_Timestampable extends IPF_ORM_Template{ public function setTableDefinition() { - if( ! $this->_options['created']['disabled']) { + if (!$this->_options['created']['disabled']) { $this->hasColumn($this->_options['created']['name'], $this->_options['created']['type'], null, $this->_options['created']['options']); } - if( ! $this->_options['updated']['disabled']) { + if (!$this->_options['updated']['disabled']) { $this->hasColumn($this->_options['updated']['name'], $this->_options['updated']['type'], null, $this->_options['updated']['options']); } $this->getTable()->listeners['Timestampable_'.print_r($this->_options, true)] = new IPF_ORM_Template_Listener_Timestampable($this->_options); } } +