I've created an entity that has a Sortable behavior and have one question about using it.
The methods for setting and getting positions are not enough for me, so I want to do simple
moveUp and moveDown methods with following code:
public function moveUp() {
++$this->position;
}
public function moveDown() {
if($this->position != 0)
--$this->position;
}
With this implementation the moveUp method has no limit for incrementing up the item with already max position. What is the best way to forbid incrementing such items? I've heard that doing custom queries directly in entities isn't a good practice, so how can I check if the item already has a max value?