本文整理汇总了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');
}
示例2: getImage
/**
* {@inheritdoc}
*/
public function getImage()
{
if ($this->images->isEmpty()) {
return $this->getProduct()->getImage();
}
return $this->images->first();
}
示例3: getImage
/**
* {@inheritdoc}
*/
public function getImage()
{
if ($this->images->isEmpty()) {
return null;
}
return $this->images->first();
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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();
}
}
示例9: testContains
/**
* @dataProvider provideCollection
*/
public function testContains(Collection $coll, array $elements)
{
$this->assertTrue($coll->contains($coll->first()));
$this->assertFalse($coll->contains(new \stdClass()));
}
示例10: first
/**
* {@inheritdoc}
*/
public function first()
{
return $this->inner->first();
}
示例11: getFirstChild
/**
* {@inheritdoc}
*/
public function getFirstChild()
{
return $this->children->first();
}
示例12: first
/** {@inheritdoc} */
public function first()
{
$this->initialize();
return $this->coll->first();
}
示例13: first
/**
* {@inheritDoc}
*/
public function first()
{
return $this->collection->first();
}
示例14: testFirst
/**
* @dataProvider provideCollection
*/
public function testFirst(Collection $coll, array $elements)
{
$this->assertSame(reset($elements), $coll->first());
}
示例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();
}