protected function _pre_store() { parent::_pre_store(); if ($this->unpublished()) { $this->time_published->clear(); $this->publisher_id = 0; if ($this->_state_when_loaded != $this->state) { // State changed; check history items and revoke notification for published items $history_item_query = $this->history_item_query(); /** @var HISTORY_ITEM[] $history_items */ $history_items = $history_item_query->objects(); foreach ($history_items as $history_item) { if ($history_item->kind == History_item_published && $history_item->publication_state == History_item_needs_send) { $history_item->publication_state = History_item_silent; $history_item->store(); } } } } elseif (!$this->time_published->is_valid()) { $this->time_published->set_now(); if ($this->update_modifier_on_change) { $this->publisher_id = $this->login->id; } else { $this->publisher_id = $this->modifier_id; } } }