private function getBacklogItemsRepresentations(PFUser $user, Planning_Milestone $milestone, $strategy)
 {
     $backlog_items = $this->getMilestoneBacklogItems($user, $milestone, $strategy);
     $backlog_items_representations = array();
     foreach ($backlog_items as $backlog_item) {
         $backlog_items_representations[] = $this->backlog_item_representation_factory->createBacklogItemRepresentation($backlog_item);
     }
     return new AgileDashboard_BacklogItem_PaginatedBacklogItemsRepresentations($backlog_items_representations, $backlog_items->getTotalAvaialableSize());
 }
 /**
  * Get backlog
  *
  * Get the backlog items of a given milestone that can be planned in a sub-milestone
  *
  * @url GET {id}/backlog
  * @access hybrid
  *
  * @param int $id     Id of the milestone
  * @param int $limit  Number of elements displayed per page
  * @param int $offset Position of the first element to display
  *
  * @return array {@type Tuleap\AgileDashboard\REST\v1\BacklogItemRepresentation}
  *
  * @throws 403
  * @throws 404
  */
 public function getBacklog($id, $limit = 10, $offset = 0)
 {
     $this->checkAccess();
     $this->checkContentLimit($limit);
     $user = $this->getCurrentUser();
     $milestone = $this->getMilestoneById($user, $id);
     $strategy = $this->backlog_strategy_factory->getBacklogStrategy($milestone, $limit, $offset);
     $backlog_items = $this->getMilestoneBacklogItems($user, $milestone, $strategy);
     $backlog_item_representation_factory = new BacklogItemRepresentationFactory();
     $backlog_items_representation = array();
     foreach ($backlog_items as $backlog_item) {
         $backlog_items_representation[] = $backlog_item_representation_factory->createBacklogItemRepresentation($backlog_item);
     }
     $this->sendAllowHeaderForBacklog();
     $this->sendPaginationHeaders($limit, $offset, $backlog_items->getTotalAvaialableSize());
     return $backlog_items_representation;
 }
 /**
  * Get the backlog items that can be planned in a top-milestone of a given project
  */
 public function get(PFUser $user, Project $project, $limit, $offset)
 {
     if (!$this->limitValueIsAcceptable($limit)) {
         throw new RestException(406, 'Maximum value for limit exceeded');
     }
     $top_milestone = $this->milestone_factory->getVirtualTopMilestone($user, $project);
     $strategy = $this->backlog_strategy_factory->getSelfBacklogStrategy($top_milestone, $limit, $offset);
     $backlog_items = $this->backlog_item_collection_factory->getUnplannedOpenCollection($user, $top_milestone, $strategy, false);
     $backlog_item_representations = array();
     $backlog_item_representation_factory = new BacklogItemRepresentationFactory();
     foreach ($backlog_items as $backlog_item) {
         $backlog_item_representations[] = $backlog_item_representation_factory->createBacklogItemRepresentation($backlog_item);
     }
     $this->sendAllowHeaders();
     $this->sendPaginationHeaders($limit, $offset, $backlog_items->getTotalAvaialableSize());
     return $backlog_item_representations;
 }
 /**
  * Get children
  *
  * Get the children of a given Backlog Item
  *
  * @url GET {id}/children
  * @access hybrid
  *
  * @param int $id     Id of the Backlog Item
  * @param int $limit  Number of elements displayed per page
  * @param int $offset Position of the first element to display
  *
  * @return array {@type Tuleap\AgileDashboard\REST\v1\BacklogItemRepresentation}
  *
  * @throws 403
  * @throws 404
  * @throws 406
  */
 public function getChildren($id, $limit = 10, $offset = 0)
 {
     $this->checkAccess();
     $this->checkContentLimit($limit);
     $current_user = $this->getCurrentUser();
     $artifact = $this->getArtifact($id);
     $backlog_items_representations = array();
     $backlog_item_representation_factory = new BacklogItemRepresentationFactory();
     $sliced_children = $this->getSlicedArtifactsBuilder()->getSlicedChildrenArtifactsForUser($artifact, $this->getCurrentUser(), $limit, $offset);
     foreach ($sliced_children->getArtifacts() as $child) {
         $backlog_item = $this->getBacklogItem($current_user, $child);
         $backlog_items_representations[] = $backlog_item_representation_factory->createBacklogItemRepresentation($backlog_item);
     }
     $this->sendAllowHeaderForChildren();
     $this->sendPaginationHeaders($limit, $offset, $sliced_children->getTotalSize());
     return $backlog_items_representations;
 }