If this slice holds has_many content
on duplicate copy the content over

@param PageSlice $slice
187055
public function onAfterDuplicate(PageSlice $slice)
    {
        // Check if there are relations set
        // Loop over each set relation
        // Copy all items in the relation over to the new object
        if ($hasManyRelations = $slice->data()->hasMany()) {
            foreach ($hasManyRelations as $relation => $class) {
                foreach ($slice->$relation() as $object) {
                    /** @var DataObject $object */
                    $copy = $object->duplicate(true);
                    $this->$relation()->add($copy);
                }
            }
        }
    }
555848
function slice(int $offset, int $limit = null, bool $preserve_keys = false) {
        $data = $this->data;
        return (new self(\array_slice($data, $offset, $limit, $preserve_keys)));
    }
753286
public function forPage($page, $perPage)
    {
        $offset = max(0, ($page - 1) * $perPage);

        return $this->slice($offset, $perPage);
    }
553024
function() {
      function isStartupSlice(slice) {
        return slice.title === 'BrowserMainLoop::CreateThreads';
      }
      var events = this.modelHelper.browserHelper.getAllAsyncSlicesMatching(
          isStartupSlice);
      var deduper = new tr.model.EventSet();
      events.forEach(function(event) {
        var sliceGroup = event.parentContainer.sliceGroup;
        var slice = sliceGroup && sliceGroup.findFirstSlice();
        if (slice)
          deduper.push(slice);
      });
      return deduper.toArray();
    }
101405
public function addSection( $section )
	{
		if ( !( isset( $this->data[$section] ) && is_array( $this->data[$section] ) ) )
			$this->data[$section]	= array();
		$this->currentSection	= $section;
	}
1331898
public function addPageFilter(Page $page)
    {
        if ($page && !$page->isRoot()) {
            $this->leftJoin('cc._mainnode', 'p')
                    ->leftJoin('p._section', 'sp')
                    ->andWhere('sp._root = :selectedPageRoot')
                    ->andWhere('sp._leftnode >= :selectedPageLeftnode')
                    ->andWhere('sp._rightnode <= :selectedPageRightnode')
                    ->setParameters([
                        'selectedPageRoot' => $page->getSection()->getRoot(),
                        'selectedPageLeftnode' => $page->getLeftnode(),
                        'selectedPageRightnode' => $page->getRightnode(),
                    ]);
        }
    }
200903
private function pagesAddNext($pagesNext = array())
    {
        $this->debug->groupCollapsed(__METHOD__);
        $pagesNext = \array_values($pagesNext);
        $pages = $this->persist->get('pages');
        $iCur = $this->persist->get('i');
        $currentPage = $pages[ $iCur ];
        // offset is where we will insert pagesNext
        $offset = $iCur + \count($currentPage['addPages']) + 1;
        foreach ($pages as $k => $page) {
            foreach ($page['addPages'] as $k2 => $i) {
                if ($i >= $offset) {
                    $pages[$k]['addPages'][$k2] += \count($pagesNext);
                }
            }
        }
        foreach ($pagesNext as $i => $pageName) {
            $pages[$k]['addPages'][] = $offset + $i;
            \array_splice($pages, $offset + $i, 0, array(
                array(
                    'name' => $pageName,
                    'completed' => false,
                    'values' => array(),
                    'addPages' => array(),
                )
            ));
        }
        $this->persist->set('pages', $pages);
        $this->debug->groupEnd();
    }
377083
private function createSliceID()
    {
        $urlFilter = URLSegmentFilter::create();
        if ($sliceID = $urlFilter->filter($this->getField('Title'))) {
            if (!$this->Parent()->PageSlices()->filter(array('ID:not' => $this->ID, 'SliceID' => $sliceID))->exists()) {
                $this->setField('SliceID', $sliceID);
            } else {
                $this->setField('SliceID', "$sliceID-{$this->ID}");
            }
        }
    }
1123325
public final void doWrites(QueuedMediaData[] slice) {
        // empty the queue
        for (QueuedMediaData queued : slice) {
            int tmpTs = queued.getTimestamp();
            if (lastWrittenTs <= tmpTs) {
                if (queued.hasData()) {
                    // write the data
                    write(queued);
                    lastWrittenTs = tmpTs;
                    // clear the data, because we're done with it
                    queued.dispose();
                } else {
                    if (log.isTraceEnabled()) {
                        log.trace("Queued data was not available");
                    }
                }
            } else {
                // clear the data, since its too old
                queued.dispose();
            }
        }
        // clear and null-out
        slice = null;
    }
762603
def _iterslice(self, slice):
        """"""
        indices = range(*slice.indices(len(self._records)))
        if self.is_attached():
            rows = self._enum_attached_rows(indices)
            if slice.step is not None and slice.step < 0:
                rows = reversed(list(rows))
        else:
            rows = zip(indices, self._records[slice])

        fields = self.fields
        for i, row in rows:
            yield Record._make(fields, row, self, i)
185433
public function clearCacheCascade(Page $page, $depth = -1){
        if ($depth == 0) return;
        $depth--;
        foreach($page->getSubpages() as $p){
            $this->clearPage($p);
            $this->clearCacheCascade($p, $depth);
        }
    }
1220507
public function page($page, $count)
    {
        $pagination = new Pagination($page, $count);
        $this->option->offset = $pagination->getLimitOffset();
        $this->option->limit = $count;
        return $this;
    }
501743
public function handleSlice()
    {
        if (!$id = $this->owner->getRequest()->param('ID')) {
            return false;
        }

        $sliceRelations = array();
        if (!$hasManyRelations = $this->owner->data()->hasMany()) {
            return false;
        }

        foreach ($hasManyRelations as $relationName => $relationClass) {
            if ($relationClass == PageSlice::class || is_subclass_of($relationClass, PageSlice::class)) {
                $sliceRelations[] = $relationName;
            }
        }

        $slice = null;
        foreach ($sliceRelations as $sliceRelation) {
            if ($slice) {
                break;
            }
            /** @var PageSlice $slice */
            $slice = $this->owner->data()->$sliceRelation()->find('ID', $id);
        }

        if (!$slice) {
            user_error('No slice found', E_USER_ERROR);
        }

        return $slice->getController();
    }
1321510
public function slice($offset, $length)
    {
        $data = array_slice($this->get(), $offset, $length);

        $this->index = $data;
        $this->meta['count'] = count($data);
    }
642357
function dp_duplicate_page( $new_post_id, $old_post_object )
	{
		// only for acf
		if( $old_post_object->post_type != "acf" )
		{
			return;
		}
		
		
		// update keys
		$metas = get_post_custom( $new_post_id );


		if( $metas )
		{
			foreach( $metas as $field_key => $field )
			{
				if( strpos($field_key, 'field_') !== false )
				{
					$field = $field[0];
					$field = maybe_unserialize( $field );
					$field = maybe_unserialize( $field ); // just to be sure!
					
					// delete old field
					delete_post_meta($new_post_id, $field_key);


					// set new keys (recursive for sub fields)
					$this->create_new_field_keys( $field );


					// save it!
					update_post_meta($new_post_id, $field['key'], $field);
					
				}
				// if( strpos($field_key, 'field_') !== false )
			}
			// foreach( $metas as $field_key => $field )
		}
		// if( $metas )
	
	}
1234826
public static function create($totalPage, $pageSize = 10, $page = 1, $gets = [])
    {
        $p = new PageUtil();
        if ($pageSize < 1) {
            $pageSize = 1;
        }

        $total = ceil($totalPage / $pageSize);

        if ($page < 1) {
            $page = 1;
        } else if ($page > $total) {
            $page = $total;
        }

        $p->page = $page;
        $p->gets = $gets;
        $p->total = $total;
        $p->pageSize = $pageSize;
        return $p;
    }
391873
private function tryToCopyFolder($folder, $inDir, $outDir, $skip=array())
    {
        // skip if not a folder
        if (!$folder->isDir()) {
            return;
        }

        // iterate recursively on all files
        $dir = new \RecursiveDirectoryIterator($folder->getRealPath());
        $it = new \RecursiveIteratorIterator($dir, \RecursiveIteratorIterator::SELF_FIRST);
        foreach ($it as $file) {
            $this->tryToCopyFile($file, $inDir, $outDir, $skip);
        }
    }