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


PHP Collection::first方法代码示例

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


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

示例1: testFirstAndLast

 public function testFirstAndLast()
 {
     $this->_coll->add('one');
     $this->_coll->add('two');
     $this->assertEquals($this->_coll->first(), 'one');
     $this->assertEquals($this->_coll->last(), 'two');
 }
开发者ID:TuxCoffeeCorner,项目名称:tcc,代码行数:7,代码来源:CollectionTest.php

示例2: getImage

 /**
  * {@inheritdoc}
  */
 public function getImage()
 {
     if ($this->images->isEmpty()) {
         return $this->getProduct()->getImage();
     }
     return $this->images->first();
 }
开发者ID:malukenho,项目名称:Sylius,代码行数:10,代码来源:ProductVariant.php

示例3: getImage

 /**
  * {@inheritdoc}
  */
 public function getImage()
 {
     if ($this->images->isEmpty()) {
         return null;
     }
     return $this->images->first();
 }
开发者ID:steffenbrem,项目名称:sylius,代码行数:10,代码来源:ProductVariant.php

示例4: getFirstDocumentSignatureFilename

 /**
  * Get filename of the first document signature
  *
  * @return null|string
  */
 public function getFirstDocumentSignatureFilename()
 {
     if ($this->getDocumentSignaturesCount() > 0) {
         /** @var DocumentSignature $signature */
         $signature = $this->documentSignatures->first();
         return $signature->getDocument()->getFilename();
     }
     return null;
 }
开发者ID:junjinZ,项目名称:wealthbot,代码行数:14,代码来源:Workflow.php

示例5:

 function it_adds_new_item_units_to_existing_shipment(OrderInterface $order, ShipmentInterface $shipment, Collection $shipments, OrderItemUnitInterface $itemUnit, OrderItemUnitInterface $itemUnitWithoutShipment)
 {
     $shipments->first()->willReturn($shipment);
     $order->hasShipments()->willReturn(true);
     $order->getItemUnits()->willReturn([$itemUnit, $itemUnitWithoutShipment]);
     $order->getShipments()->willReturn($shipments);
     $itemUnit->getShipment()->willReturn($shipment);
     $shipment->addUnit($itemUnitWithoutShipment)->shouldBeCalled();
     $shipment->addUnit($itemUnit)->shouldNotBeCalled();
     $this->processOrderShipment($order);
 }
开发者ID:ahmadrabie,项目名称:Sylius,代码行数:11,代码来源:OrderShipmentProcessorSpec.php

示例6: getLastShipment

 /**
  * Gets the last updated shipment of the order
  *
  * @return false|ShipmentInterface
  */
 public function getLastShipment()
 {
     if ($this->shipments->isEmpty()) {
         return false;
     }
     $last = $this->shipments->first();
     foreach ($this->shipments as $shipment) {
         if ($shipment->getUpdatedAt() > $last->getUpdatedAt()) {
             $last = $shipment;
         }
     }
     return $last;
 }
开发者ID:vikey89,项目名称:Sylius,代码行数:18,代码来源:Order.php

示例7: findBranch

 /**
  * @param Collection|TaxonomyTermInterface[] $collection
  * @return TaxonomyTermInterface|null
  */
 public function findBranch(Collection $collection)
 {
     if (empty($collection)) {
         return null;
     }
     $maxDepth = 9999;
     $item = $collection->first();
     foreach ($collection as $term) {
         $depth = $this->iterBranch($term, $maxDepth);
         if ($depth < $maxDepth) {
             $maxDepth = $depth;
             $item = $term;
         }
     }
     return $item;
 }
开发者ID:andreas-serlo,项目名称:athene2,代码行数:20,代码来源:ShortestBranchDecisionMaker.php

示例8: generateCells

 /**
  * Generates the cells.
  *
  * @param TableView $view
  */
 private function generateCells(TableView $view)
 {
     $sortDirs = [ColumnSort::ASC, ColumnSort::DESC];
     $columns = $this->config->getColumns();
     foreach ($columns as &$columnOptions) {
         $key = $columnOptions['full_name'] . '_sort';
         $sortDir = $this->requestHelper->getVar($key, ColumnSort::NONE);
         $columnOptions['sorted'] = in_array($sortDir, $sortDirs);
     }
     unset($columnOptions);
     $this->data->first();
     while ($this->data->current()) {
         $row = new Row($this->getCurrentRowData('id'));
         // TODO getCurrentRowKey() ?
         foreach ($columns as $columnOptions) {
             $cell = new Cell();
             $type = $this->factory->getColumnType($columnOptions['type']);
             $type->buildViewCell($cell, $this, $columnOptions);
             $row->cells[] = $cell;
         }
         $view->rows[] = $row;
         $this->data->next();
     }
 }
开发者ID:ekyna,项目名称:table,代码行数:29,代码来源:Table.php

示例9: testContains

 /**
  * @dataProvider provideCollection
  */
 public function testContains(Collection $coll, array $elements)
 {
     $this->assertTrue($coll->contains($coll->first()));
     $this->assertFalse($coll->contains(new \stdClass()));
 }
开发者ID:malarzm,项目名称:collections,代码行数:8,代码来源:ObjectSetTest.php

示例10: first

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

示例11: getFirstChild

 /**
  * {@inheritdoc}
  */
 public function getFirstChild()
 {
     return $this->children->first();
 }
开发者ID:superdesk,项目名称:web-publisher,代码行数:7,代码来源:MenuItem.php

示例12: first

 /** {@inheritdoc} */
 public function first()
 {
     $this->initialize();
     return $this->coll->first();
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:6,代码来源:PersistentCollection.php

示例13: first

 /**
  * {@inheritDoc}
  */
 public function first()
 {
     return $this->collection->first();
 }
开发者ID:cross-solution,项目名称:yawik,代码行数:7,代码来源:IdentityWrapper.php

示例14: testFirst

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

示例15: hasOfferVariants

 /**
  * @return bool
  */
 public function hasOfferVariants()
 {
     if (count($this->quoteProductOffers) > 1) {
         return true;
     }
     /** @var QuoteProductOffer $firstItem */
     $firstItem = $this->quoteProductOffers->first();
     return $firstItem && $firstItem->isAllowIncrements();
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:12,代码来源:QuoteProduct.php


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