/** * Add an item to the backlog of a milestone * * Add an item to the backlog of a milestone * * The item must be of the allowed types (defined in the planning configuration). * The body of the request should be of the form : * { * "artifact" : { * "id" : 458 * } * } * * @url POST {id}/backlog * * @param int $id Id of the milestone * @param BacklogItemReference $item Reference of the Backlog Item {@from body} {@type BacklogItemReference} * * @throw 400 * @throw 403 * @throw 404 */ protected function postBacklog($id, BacklogItemReference $item) { $user = $this->getCurrentUser(); $milestone = $this->getMilestoneById($user, $id); $this->checkIfUserCanChangePrioritiesInMilestone($milestone, $user); $item_id = $item->getArtifactId(); $artifact = $this->getBacklogItemAsArtifact($user, $item_id); $allowed_trackers = $this->backlog_strategy_factory->getBacklogStrategy($milestone)->getDescendantTrackers(); if (!$this->milestone_validator->canBacklogItemBeAddedToMilestone($artifact, $allowed_trackers)) { throw new RestException(400, "Item of type '" . $artifact->getTracker()->getName() . "' cannot be added."); } try { $this->milestone_content_updater->appendElementToMilestoneBacklog($item_id, $user, $milestone); } catch (Tracker_NoChangeException $e) { } $this->sendAllowHeaderForBacklog(); }