private function addState($order, $label) { $previous = $this->states->findOneBy(['label' => $label]); if ($previous) { $this->messages[] = "~ State '{$label}' already exists and was not added."; return; } $state = new State(); $state->sequence = $order; $state->label = $label; $this->states->save($state, false); $this->messages[] = "+ Addomg state '{$label}'."; }
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(); }