當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ArrayCollection::first方法代碼示例

本文整理匯總了PHP中Doctrine\Common\Collections\ArrayCollection::first方法的典型用法代碼示例。如果您正苦於以下問題:PHP ArrayCollection::first方法的具體用法?PHP ArrayCollection::first怎麽用?PHP ArrayCollection::first使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\Common\Collections\ArrayCollection的用法示例。


在下文中一共展示了ArrayCollection::first方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: first

 public function first()
 {
     if (null === $this->entries) {
         $this->__load___();
     }
     return $this->entries->first();
 }
開發者ID:luisbrito,項目名稱:Phraseanet,代碼行數:7,代碼來源:AggregateEntryCollection.php

示例2: getAuditEntryFieldClass

 /**
  * @param DiamanteUser|null $user
  *
  * @return string
  */
 public function getAuditEntryFieldClass(DiamanteUser $user = null)
 {
     if ($user === null) {
         return $this->entryFieldMap->first();
     }
     $userClass = ClassUtils::getRealClass($user);
     if (!$this->entryFieldMap->containsKey($userClass)) {
         throw new \InvalidArgumentException(sprintf('Audit entry field not found for "%s"', $userClass));
     }
     return $this->entryFieldMap->get($userClass);
 }
開發者ID:gitter-badger,項目名稱:diamantedesk-application,代碼行數:16,代碼來源:AuditEntityMapper.php

示例3: getPreviewImage

 /**
  * Get preview image
  *
  * @return Image
  */
 public function getPreviewImage()
 {
     if ($this->images->containsKey($this->previewImageKey)) {
         return $this->images->get($this->previewImageKey);
     }
     return $this->images->first();
 }
開發者ID:nathix86,項目名稱:bcp-website,代碼行數:12,代碼來源:Post.php

示例4: findEnabledReferralRuleFromDateTime

 /**
  * Get first enabled referral rule, given a DateTime
  *
  * @param DateTime $dateTime DateTime instance
  *
  * @return ReferralRule Instance found
  */
 public function findEnabledReferralRuleFromDateTime(DateTime $dateTime)
 {
     $queryBuilder = $this->createQueryBuilder('r');
     $queryResults = $queryBuilder->where('r.enabled = :enabled')->andWhere('r.validFrom <= :datetime')->andWhere($queryBuilder->expr()->orx($queryBuilder->expr()->gte('r.validTo', ':datetime'), $queryBuilder->expr()->isNull('r.validTo')))->orderBy('r.id', 'DESC')->setMaxResults(1)->setParameters(array('enabled' => true, 'datetime' => $dateTime))->getQuery()->getResult();
     $rules = new ArrayCollection($queryResults);
     return $rules->first();
 }
開發者ID:hd-deman,項目名稱:elcodi,代碼行數:14,代碼來源:ReferralRuleRepository.php

示例5: getMediaForThumbnail

 /**
  * @return AbstractMediaEntity|null
  */
 public function getMediaForThumbnail()
 {
     if ($this->media->count() > 0) {
         return $this->media->first();
     }
     return null;
 }
開發者ID:shefik,項目名稱:MediaModule,代碼行數:10,代碼來源:CollectionEntity.php

示例6: getDefaultColumn

 /**
  * @return Column
  */
 public function getDefaultColumn()
 {
     if (!empty($this->defaultColumn)) {
         return $this->defaultColumn;
     } else {
         return $this->columnCollection->first();
     }
 }
開發者ID:Silwereth,項目名稱:core,代碼行數:11,代碼來源:SortableColumns.php

示例7:

 function it_adds_new_inventory_units_to_existing_shipment(OrderInterface $order, ShipmentInterface $shipment, ArrayCollection $shipments, InventoryUnitInterface $inventoryUnit, InventoryUnitInterface $inventoryUnitWithoutShipment)
 {
     $shipments->first()->willReturn($shipment)->shouldBeCalled();
     $inventoryUnit->getShipment()->willReturn($shipment);
     $order->getInventoryUnits()->willReturn(array($inventoryUnit, $inventoryUnitWithoutShipment));
     $order->getShipments()->willReturn($shipments)->shouldBeCalled();
     $shipment->addItem($inventoryUnitWithoutShipment)->shouldBeCalled();
     $shipment->addItem($inventoryUnit)->shouldNotBeCalled();
     $this->createShipment($order);
 }
開發者ID:bcremer,項目名稱:Sylius,代碼行數:10,代碼來源:ShipmentFactorySpec.php

示例8: titleField

 /**
  * Guestimate the title field of the model.
  *
  * @return mixed
  */
 function titleField()
 {
     $keys = ['title', 'name', 'host', 'url', 'email'];
     foreach ($keys as $key) {
         if ($this->fields->containsKey($key)) {
             return $key;
         }
     }
     return $this->fields->first()->name;
 }
開發者ID:mattcrowe,項目名稱:ginny,代碼行數:15,代碼來源:BaseModel.php

示例9: getCategory

 /**
  * @return Category
  */
 public function getCategory()
 {
     if ($this->enrollments->count() > 1) {
         throw new ValidationException("INVALIDENROLLMENT", "A team can not be enrolled for more than one category - team id=" . $this->id);
     }
     if ($this->enrollments->count() == 1) {
         return $this->enrollments->first()->getCategory();
     }
     return null;
 }
開發者ID:armandomeeuwenoord,項目名稱:icup,代碼行數:13,代碼來源:Team.php

示例10:

 function it_adds_new_item_units_to_existing_shipment(OrderInterface $order, ShipmentInterface $shipment, ArrayCollection $shipments, OrderItemUnitInterface $itemUnit, OrderItemUnitInterface $itemUnitWithoutShipment)
 {
     $shipments->first()->willReturn($shipment)->shouldBeCalled();
     $order->hasShipments()->willReturn(true)->shouldBeCalled();
     $itemUnit->getShipment()->willReturn($shipment);
     $order->getItemUnits()->willReturn([$itemUnit, $itemUnitWithoutShipment]);
     $order->getShipments()->willReturn($shipments)->shouldBeCalled();
     $shipment->addUnit($itemUnitWithoutShipment)->shouldBeCalled();
     $shipment->addUnit($itemUnit)->shouldNotBeCalled();
     $this->createForOrder($order);
 }
開發者ID:vikey89,項目名稱:Sylius,代碼行數:11,代碼來源:OrderShipmentFactorySpec.php

示例11: start

 /**
  * @see ExecutableInterface::start()
  */
 public function start()
 {
     if (!$this->started) {
         $this->batch->startTimer($this->name, 'start');
         $this->setStarted();
         // Start first UnitProcedure
         if ($this->unitProcedures->count()) {
             $unitProcedure = $this->unitProcedures->first();
             $unitProcedure->setEventDispatcher($this->eventDispatcher);
             $unitProcedure->start();
         }
     }
 }
開發者ID:evertharmeling,項目名稱:brouwkuyp-control,代碼行數:16,代碼來源:Procedure.php

示例12: start

 /**
  * @see ExecutableInterface::start()
  */
 public function start()
 {
     if (!$this->started) {
         $this->batch->startTimer($this->name, 'start');
         $this->setStarted();
         // Start first Operation
         if ($this->operations->count()) {
             $operation = $this->operations->first();
             $operation->setEventDispatcher($this->eventDispatcher);
             $operation->start();
         }
     }
 }
開發者ID:evertharmeling,項目名稱:brouwkuyp-control,代碼行數:16,代碼來源:UnitProcedure.php

示例13: start

 /**
  * Starts the operation
  */
 public function start()
 {
     if (!$this->started) {
         $this->batch->startTimer($this->name, 'start');
         // Set flag that we are started
         $this->setStarted();
         // Start first UnitProcedure
         if ($this->phases->count()) {
             $phase = $this->phases->first();
             $phase->setEventDispatcher($this->eventDispatcher);
             $phase->start();
         }
     }
 }
開發者ID:evertharmeling,項目名稱:brouwkuyp-control,代碼行數:17,代碼來源:Operation.php

示例14: testGetIterator

 /**
  * @dataProvider getNodes
  *
  * @param int $total_pages
  * @param string|\Closure $page_link
  * @param string $first_page_link
  * @param ArrayCollection $list
  */
 public function testGetIterator($total_pages, $page_link, $first_page_link, $list)
 {
     $current_page = 1;
     foreach ($list as $node) {
         /** @var $node Node */
         if ($node->isCurrent()) {
             $current_page = $node->getPage();
         }
     }
     $left_offset = $current_page - $list->first()->getPage();
     $right_offset = $list->last()->getPage() - $current_page;
     if ($list->first()->getPage() == 1) {
         $this->config->expects($this->once())->method('getFirstPageLink')->will($this->returnValue($first_page_link));
     } else {
         $this->config->expects($this->never())->method('getFirstPageLink');
     }
     $this->config->expects($this->once())->method('getTotalPages')->will($this->returnValue($total_pages));
     $this->config->expects($this->atLeastOnce())->method('getCurrentPage')->will($this->returnValue($current_page));
     $this->config->expects($this->atLeastOnce())->method('getPageLink')->will($this->returnValue($page_link));
     $this->range->expects($this->once())->method('getLeftOffset')->will($this->returnValue($left_offset));
     $this->range->expects($this->once())->method('getRightOffset')->will($this->returnValue($right_offset));
     $this->assertEquals($list, $this->view->getIterator());
 }
開發者ID:anime-db,項目名稱:pagination-bundle,代碼行數:31,代碼來源:ViewTest.php

示例15: testFirst

 /**
  * @dataProvider provideDifferentElements
  */
 public function testFirst($elements)
 {
     $collection = new ArrayCollection($elements);
     $this->assertSame(reset($elements), $collection->first());
 }
開發者ID:tccLaravel,項目名稱:test4,代碼行數:8,代碼來源:ArrayCollectionTest.php


注:本文中的Doctrine\Common\Collections\ArrayCollection::first方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。