本文整理汇总了PHP中Doctrine\Common\Collections\ArrayCollection::last方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayCollection::last方法的具体用法?PHP ArrayCollection::last怎么用?PHP ArrayCollection::last使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Collections\ArrayCollection
的用法示例。
在下文中一共展示了ArrayCollection::last方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: last
public function last()
{
if (null === $this->entries) {
$this->__load___();
}
return $this->entries->last();
}
示例2: getServiceEvent
/**
*
* @return ServiceEvent
*/
public function getServiceEvent()
{
if (!$this->serviceEvents) {
$serviceEvent = new ServiceEvent();
$this->setServiceEvent($serviceEvent);
}
return $this->serviceEvents->last();
}
示例3: append
public function append($output, $error)
{
$processOutput = new ProcessOutput();
$last = $this->outputs->last();
$processOutput->setNumber($last ? ++$last->number : 1);
$processOutput->setCreated(new \DateTime());
$processOutput->setValue($output);
$processOutput->setError($error);
$processOutput->setProcess($this);
$this->outputs[] = $processOutput;
}
示例4: __construct
/**
* @param string
* @param string
* @param array
*/
public function __construct($departure, $arrival, array $steps = array())
{
$this->departure = (string) $departure;
$this->arrival = (string) $arrival;
$this->steps = new ArrayCollection();
foreach ($steps as $step) {
$this->addStep($step);
}
if ($this->steps->last() != NULL) {
$this->lastSequenceOrder = $this->steps->last()->sequenceOrder;
}
}
示例5: getSessions
public function getSessions(Event $event)
{
$sessions = new ArrayCollection();
$this->crawler->filter('#snippet--program dt')->each(function (Crawler $dt) use($sessions, $event) {
$session = new Session();
$session->setEvent($event);
$time = new \DateTime($dt->text(), new \DateTimeZone('Europe/Prague'));
$date = clone $event->getStart();
$date->setTime($time->format('H'), $time->format('i'), $time->format('s'));
$session->setStart($date);
if ($previousSession = $sessions->last()) {
$previousSession->setStop($date);
}
$sessions->add($session);
});
$this->crawler->filter('#snippet--program dd')->each(function (Crawler $dd, $i) use($sessions) {
$session = $sessions[$i];
if (preg_match('/program-type-([^ ]+)/', $dd->attr('class'), $matches)) {
$session->setType($matches[1]);
}
$title = $dd->filter('.program-title');
$speaker = $dd->filter('.program-speaker');
$description = $dd->filter('.program-desc');
if (count($title)) {
$session->setTitle(trim($title->text()));
}
if (count($speaker)) {
$session->setSpeaker(trim($speaker->text()));
}
if (count($description)) {
$session->setDescription(trim($description->text()));
}
});
return $sessions;
}
示例6: getQBAliasReference
public function getQBAliasReference($class, $attribute = NULL)
{
if (!is_object($class)) {
throw new \Exception("object must be of type object, type %s given.", gettype($class));
}
$class_name = get_class($class);
// get alias of class
$alias = NULL;
foreach ($this->qb_alias_reference->toArray() as $_class => $_alias) {
if (isset($_alias[$class_name])) {
$alias = $_alias[$class_name];
}
}
// if not found
if ($alias === NULL) {
// if empty, set new
if ($this->qb_alias_reference->count() == 0) {
$alias = 'a';
// get last and then count up
} else {
$lastAlias = $this->qb_alias_reference->last();
$alias = ++$lastAlias[key($lastAlias)];
}
// add new
$this->qb_alias_reference->add(array($class_name => $alias));
}
return $attribute === NULL ? $alias : $alias . '.' . $attribute;
}
示例7: isUnread
/**
* Gets whether the user has read this thread since the last post
*
* @param User $user
*
* @return boolean
*/
public function isUnread(User $user)
{
if ($this->posts->count() === 0) {
return false;
}
return $this->posts->last()->isUnread($user);
}
示例8: indexAction
public function indexAction(Application $app, Request $request, $url)
{
if ($url) {
$urlParts = new ArrayCollection(explode('/', $url));
$last = $urlParts->last();
$page = $app['em']->getRepository('CMSilex\\Entities\\Page')->findOneBy(['slug' => $last]);
if ($page) {
$template = $page->getTemplate();
return $app->render('@theme/' . $template . '.html.twig', ['page' => $page]);
} else {
throw new NotFoundHttpException();
}
}
throw new NotFoundHttpException();
}
示例9: getCurrentStationState
/**
* @return StationState
*/
public function getCurrentStationState()
{
return $this->stationStates->last();
}
示例10: getLastState
/**
* {@inheritdoc}
*/
public function getLastState()
{
return $this->states->last() ?: null;
}
示例11: last
/**
* Sets the internal iterator to the last element in the collection and returns this element.
*
* @return mixed
*/
public function last()
{
return $this->collection->last();
}
示例12: last
/** {@inheritDoc} */
public function last()
{
$this->initialize();
return $this->collection->last();
}
示例13: 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());
}
示例14: testLast
/**
* Tests IdentityWrapper->last()
*/
public function testLast()
{
$expected = end($this->entries);
$this->assertSame($expected, $this->identityWrapper->last());
$this->assertSame($expected, $this->wrappedCollection->last());
}
示例15: estimateRange
/**
* Get estimate points
*
* @param EloPlayerInterface $player
*
* @return integer
*/
private function estimateRange(EloPlayerInterface $player)
{
$baseRange = new ArrayCollection($this->configuration->getBaseRange());
$keys = array_keys($this->configuration->getBaseRange());
$estimatedRange = $baseRange->first();
$i = 0;
foreach ($baseRange as $eloMin => $range) {
if (!isset($keys[$i + 1]) && $player->getElo() > $baseRange->last()) {
$estimatedRange = $baseRange->last();
break;
}
if ($player->getElo() >= $eloMin && isset($keys[$i + 1]) && $player->getElo() <= $keys[$i + 1]) {
$estimatedRange = $range;
break;
}
$i++;
}
return $estimatedRange;
}