当前位置: 首页>>代码示例>>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;未经允许,请勿转载。