Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function getSlice($offset, $length)
 {
     $items = array();
     $resources = parent::getSlice($offset, $length);
     try {
         foreach ($resources as $itemData) {
             $items[] = new Item($itemData);
         }
     } catch (Exception $e) {
         throw new InvalidDataException('Could not convert resources to items.', $e->getCode(), $e);
     }
     return $items;
 }
 /**
  * {@inheritdoc}
  */
 public function getSlice($offset, $length)
 {
     $packages = array();
     $resources = parent::getSlice($offset, $length);
     try {
         foreach ($resources as $itemData) {
             $packages[] = new Package($itemData);
         }
         if ($this->resolveAssociations) {
             foreach ($packages as $id => $package) {
                 $associations = $this->apiInstance->getAssociationsFromPackage($package);
                 $packages[$id] = $this->apiInstance->injectAssociations($package, $associations);
             }
         }
     } catch (Exception $e) {
         throw new InvalidDataException('Could not convert resources to packages.', $e->getCode(), $e);
     }
     return $packages;
 }