set('old', $old); $validator = new Validator($_REQUEST); if ($validator->errors->count()) { $session->set('errors', $validator->errors); redirectAndExit('/create'); } $validated = $validator->validated; $todos = new TodoRepository($config['path_to_repository']); $todo = new Todo(); $todo->task = $validated->task; $todo->tag = $validated->tag; $todo->addedAt = date('Y-m-d H:i:s'); if (!$todos->add($todo)) { respondAndExit(500, 'Internal Server Error'); } $session->set('message', 'Todo Added'); redirectAndExit('/');