public function handleSort() { $order = $this->getParameter('sort'); foreach ($order as $sequence => $id) { /** @var State $state */ $state = $this->states->find($id); $state->sequence = $sequence + 1; $this->states->save($state, false); } $this->states->flush(); }