Esempio n. 1
0
 /**
  * @param int $itemsPerPage
  * @param int $offset
  *
  * @return array|QueryResultInterface
  * @throws \InvalidArgumentException
  */
 protected function prepareObjectsSlice($itemsPerPage, $offset)
 {
     if ($this->objects instanceof QueryResultInterface) {
         $query = $this->objects->getQuery();
         $query->setLimit($itemsPerPage);
         if ($offset > 0) {
             $query->setOffset($offset);
         }
         $modifiedObjects = $query->execute();
         return $modifiedObjects;
     } elseif ($this->objects instanceof ObjectStorage) {
         $modifiedObjects = array();
         $endOfRange = $offset + $itemsPerPage;
         for ($i = $offset; $i < $endOfRange; $i++) {
             $modifiedObjects[] = $this->objects->toArray()[$i];
         }
         return $modifiedObjects;
     } elseif (is_array($this->objects)) {
         $modifiedObjects = array_slice($this->objects, $offset, $itemsPerPage);
         return $modifiedObjects;
     } else {
         throw new \InvalidArgumentException('The view helper "' . get_class($this) . '" accepts as argument "QueryResultInterface", "\\SplObjectStorage", "ObjectStorage" or an array. ' . 'given: ' . get_class($this->objects), 1385547291);
     }
 }
Esempio n. 2
0
 /**
  * @return array
  *
  * @see \TYPO3\CMS\Extbase\Persistence\ObjectStorage::toArray
  */
 public function toArray()
 {
     $this->initialize();
     return parent::toArray();
 }