当前位置: 首页>>代码示例>>PHP>>正文


PHP Collection::slice方法代码示例

本文整理汇总了PHP中Doctrine\Common\Collections\Collection::slice方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::slice方法的具体用法?PHP Collection::slice怎么用?PHP Collection::slice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\Common\Collections\Collection的用法示例。


在下文中一共展示了Collection::slice方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: slice

 /**
  * {@inheritDoc}
  */
 public function slice($offset, $length = null)
 {
     $array = [];
     foreach ($this->collection->slice($offset, $length) as $element) {
         $array[$this->getKey($element)] = $element;
     }
     return $array;
 }
开发者ID:cross-solution,项目名称:yawik,代码行数:11,代码来源:IdentityWrapper.php

示例2: testSlice

 public function testSlice()
 {
     $this->_coll[] = 'one';
     $this->_coll[] = 'two';
     $this->_coll[] = 'three';
     $slice = $this->_coll->slice(0, 1);
     $this->assertInternalType('array', $slice);
     $this->assertEquals(array('one'), $slice);
     $slice = $this->_coll->slice(1);
     $this->assertEquals(array(1 => 'two', 2 => 'three'), $slice);
     $slice = $this->_coll->slice(1, 1);
     $this->assertEquals(array(1 => 'two'), $slice);
 }
开发者ID:TuxCoffeeCorner,项目名称:tcc,代码行数:13,代码来源:CollectionTest.php

示例3: normalizeWarnings

 /**
  * Normalizes the warnings
  *
  * @param Collection $warnings
  * @param array      $context
  *
  * @return array
  */
 protected function normalizeWarnings(Collection $warnings, array $context = [])
 {
     $result = [];
     $selectedWarnings = [];
     if (isset($context['limit_warnings']) && $context['limit_warnings'] > 0) {
         $selectedWarnings = $warnings->slice(0, $context['limit_warnings']);
     } else {
         $selectedWarnings = $warnings;
     }
     foreach ($selectedWarnings as $warning) {
         $result[] = ['label' => $this->translator->trans($warning->getName()), 'reason' => $this->translator->trans($warning->getReason(), $warning->getReasonParameters()), 'item' => $warning->getItem()];
     }
     return $result;
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:22,代码来源:StepExecutionNormalizer.php

示例4: slice

 /**
  * Extract a slice of $length elements starting at position $offset from the Collection.
  *
  * If $length is null it returns all elements from $offset to the end of the Collection.
  * Keys have to be preserved by this method. Calling this method will only return the
  * selected slice and NOT change the elements contained in the collection slice is called on.
  *
  * @param int $offset
  * @param int $length
  * @return array
  */
 public function slice($offset, $length = null)
 {
     if (!$this->initialized && !$this->isDirty && $this->association['fetch'] == Mapping\ClassMetadataInfo::FETCH_EXTRA_LAZY) {
         return $this->em->getUnitOfWork()->getCollectionPersister($this->association)->slice($this, $offset, $length);
     }
     $this->initialize();
     return $this->coll->slice($offset, $length);
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:19,代码来源:PersistentCollection.php

示例5: slice

 /**
  * {@inheritDoc}
  */
 public function slice($offset, $length = null)
 {
     $this->initialize();
     return $this->collection->slice($offset, $length);
 }
开发者ID:BozzaCoon,项目名称:SPHERE-Framework,代码行数:8,代码来源:AbstractLazyCollection.php

示例6: findAll

 /**
  * {@inheritdoc}
  */
 public function findAll($page = 1, $pageSize = null)
 {
     return array_values($this->taskExecutionCollection->slice(($page - 1) * $pageSize, $pageSize));
 }
开发者ID:php-task,项目名称:php-task,代码行数:7,代码来源:ArrayTaskExecutionRepository.php

示例7: getItems

 /**
  * {@inheritDoc}
  */
 public function getItems($offset, $itemCountPerPage)
 {
     return array_values($this->collection->slice($offset, $itemCountPerPage));
 }
开发者ID:KBO-Techo-Dev,项目名称:MagazinePro-zf25,代码行数:7,代码来源:Collection.php

示例8: extractCommentsPage

 public static function extractCommentsPage(Collection $comments, $from)
 {
     return ['from' => $from, 'entities' => $comments->slice($from, AbstractCommentRepository::COMMENTS_PER_PAGE), 'total_count' => $comments->count(), 'entities_per_page' => self::COMMENTS_PER_PAGE];
 }
开发者ID:kipelovets,项目名称:kipelovets,代码行数:4,代码来源:AbstractCommentRepository.php

示例9: extractPage

 public static function extractPage(Collection $collection, $from)
 {
     return ['from' => $from, 'entities' => $collection->slice($from, self::getEntitiesPerPage()), 'total_count' => $collection->count(), 'entities_per_page' => self::getEntitiesPerPage()];
 }
开发者ID:kipelovets,项目名称:kipelovets,代码行数:4,代码来源:ArticleRepository.php

示例10: slice

 /**
  * {@inheritdoc}
  */
 public function slice($offset, $length = null)
 {
     return $this->inner->slice($offset, $length);
 }
开发者ID:peterkrejci,项目名称:music-collection,代码行数:7,代码来源:ReadOnlyCollectionWrapper.php

示例11: testSlice

 /**
  * @dataProvider provideCollection
  */
 public function testSlice(Collection $coll, array $elements)
 {
     $this->assertSame(array_slice($elements, 0, -1, true), $coll->slice(0, -1));
 }
开发者ID:malarzm,项目名称:collections,代码行数:7,代码来源:BaseTest.php

示例12: getScores

 /**
  * Get all historical scores indexed by date
  *
  * @param integer $limit
  *
  * @return array
  */
 public function getScores($limit = null)
 {
     if (null === $limit) {
         return $this->scores;
     }
     return $this->scores->slice(0, $limit);
 }
开发者ID:KnpLabs,项目名称:KnpBundles,代码行数:14,代码来源:Bundle.php

示例13: slice

 /**
  * Slices a doctrine collection from an array of filters
  * @param  Collection                $storeNewsCollection
  * @param  array                     $filters
  * @throws \InvalidArgumentException
  * @return array
  * @author Yohann Marillet
  */
 public function slice(Collection $collection, array $filters)
 {
     if (!isset($filters['offset'])) {
         throw new \InvalidArgumentException('Filter key "offset" must be specified');
     }
     if (!isset($filters['limit'])) {
         $filters['limit'] = null;
     } else {
         $filters['limit'] = (int) $filters['limit'];
     }
     $return = $collection->slice((int) $filters['offset'], $filters['limit']);
     return $return;
 }
开发者ID:ymarillet,项目名称:sknife,代码行数:21,代码来源:AbstractRepository.php


注:本文中的Doctrine\Common\Collections\Collection::slice方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。