當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。