本文整理汇总了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();
}
示例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);
}
示例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();
}
示例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();
}
示例5: getMediaForThumbnail
/**
* @return AbstractMediaEntity|null
*/
public function getMediaForThumbnail()
{
if ($this->media->count() > 0) {
return $this->media->first();
}
return null;
}
示例6: getDefaultColumn
/**
* @return Column
*/
public function getDefaultColumn()
{
if (!empty($this->defaultColumn)) {
return $this->defaultColumn;
} else {
return $this->columnCollection->first();
}
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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();
}
}
}
示例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();
}
}
}
示例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();
}
}
}
示例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());
}
示例15: testFirst
/**
* @dataProvider provideDifferentElements
*/
public function testFirst($elements)
{
$collection = new ArrayCollection($elements);
$this->assertSame(reset($elements), $collection->first());
}