/** * Sets the sort property to the current sort value * * @param Model Model object subject of this observer method */ public function before_insert(Orm\Model $obj) { if ($obj instanceof SortableInterface) { $max = $obj->getSortMax(); } else { $max = $obj->query()->max($this->_property); } $obj->{$this->_property} = $max + $this->_offset; }