user; $workspace = $user->createWorkspace($cmd->name); if ($cmd->address) { $workspace->setAddress($cmd->address); } // Add the workspace to the repository $this->repo->add($workspace); // Dispatch the workspace created event $event = new WorkspaceCreatedEvent($workspace); $this->dispatcher->dispatch($event); return $workspace; } }