public function __construct(States $states, Colors $colors) { parent::__construct(); $this->states = $states; $this->ordered = $this->states->findBy([], ['sequence' => 'ASC']); $this->colors = $colors; }
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(); }