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


PHP ArrayCollection::last方法代碼示例

本文整理匯總了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();
 }
開發者ID:luisbrito,項目名稱:Phraseanet,代碼行數:7,代碼來源:AggregateEntryCollection.php

示例2: getServiceEvent

 /**
  *
  * @return ServiceEvent
  */
 public function getServiceEvent()
 {
     if (!$this->serviceEvents) {
         $serviceEvent = new ServiceEvent();
         $this->setServiceEvent($serviceEvent);
     }
     return $this->serviceEvents->last();
 }
開發者ID:arstropica,項目名稱:zf2-dashboard,代碼行數:12,代碼來源:ServiceEventTrait.php

示例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;
 }
開發者ID:rixxi,項目名稱:watch-process,代碼行數:11,代碼來源:Process.php

示例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;
     }
 }
開發者ID:jff15,項目名稱:travelbot,代碼行數:17,代碼來源:Trip.php

示例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;
 }
開發者ID:webuni,項目名稱:srazy-api-client,代碼行數:35,代碼來源:EventPage.php

示例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;
 }
開發者ID:RSSfeed,項目名稱:AdminBundle,代碼行數:28,代碼來源:AdminSearch.php

示例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);
 }
開發者ID:madrakio,項目名稱:streamperk-forum-bundle,代碼行數:14,代碼來源:ForumThread.php

示例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();
 }
開發者ID:cmsilex,項目名稱:cmsilex,代碼行數:15,代碼來源:FrontendController.php

示例9: getCurrentStationState

 /**
  * @return StationState
  */
 public function getCurrentStationState()
 {
     return $this->stationStates->last();
 }
開發者ID:alexcarol,項目名稱:bicing-stats,代碼行數:7,代碼來源:Station.php

示例10: getLastState

 /**
  * {@inheritdoc}
  */
 public function getLastState()
 {
     return $this->states->last() ?: null;
 }
開發者ID:cleentfaar,項目名稱:windmill,代碼行數:7,代碼來源:Game.php

示例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();
 }
開發者ID:Rybbow,項目名稱:x-blog,代碼行數:9,代碼來源:ImmutableCollection.php

示例12: last

 /** {@inheritDoc} */
 public function last()
 {
     $this->initialize();
     return $this->collection->last();
 }
開發者ID:nikophil,項目名稱:cmf-tests,代碼行數:6,代碼來源:PersistentCollection.php

示例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());
 }
開發者ID:anime-db,項目名稱:pagination-bundle,代碼行數:31,代碼來源:ViewTest.php

示例14: testLast

 /**
  * Tests IdentityWrapper->last()
  */
 public function testLast()
 {
     $expected = end($this->entries);
     $this->assertSame($expected, $this->identityWrapper->last());
     $this->assertSame($expected, $this->wrappedCollection->last());
 }
開發者ID:cross-solution,項目名稱:yawik,代碼行數:9,代碼來源:IdentityWrapperTest.php

示例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;
 }
開發者ID:avoo,項目名稱:elo,代碼行數:26,代碼來源:AbstractElo.php


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