/** * @param string $text * @return TodoList */ public function createList($text) { $todoList = new TodoList(); $todoList->setName($text); $this->objectManager->persist($todoList); $this->objectManager->flush(); return $todoList; }
/** * @param TodoList $list * @return array */ private function formatList(TodoList $list) { return ['id' => $list->getId(), 'name' => $list->getName(), 'tasks' => $list->getTasks()->map(function (Task $task) { return $task->getId(); })->toArray()]; }