Author: FabianLange
Date: 2010-02-06 00:42:30 +0100 (Sat, 06 Feb 2010)
New Revision: 27612
Modified:
branches/1.3/lib/addon/sfPager.class.php
branches/1.4/lib/addon/sfPager.class.php
Log:
[1.3, 1.4] added basic test for sfPager->rewind() and fixed bug not leading to
->reset() not working correctly. (fixes #8021)
Modified: branches/1.3/lib/addon/sfPager.class.php
===================================================================
--- branches/1.3/lib/addon/sfPager.class.php 2010-02-05 21:22:59 UTC (rev
27611)
+++ branches/1.3/lib/addon/sfPager.class.php 2010-02-05 23:42:30 UTC (rev
27612)
@@ -493,6 +493,15 @@
$this->parameterHolder->set($name, $value);
}
+ protected function initResultsIfRequired()
+ {
+ if (null === $this->results)
+ {
+ $this->results = $this->getResults();
+ $this->resultsCounter = count($this->results);
+ }
+ }
+
/**
* Returns the current result.
*
@@ -500,11 +509,7 @@
*/
public function current()
{
- if (null === $this->results)
- {
- $this->results = $this->getResults();
- $this->resultsCounter = count($this->results);
- }
+ $this->initResultsIfRequired();
return current($this->results);
}
@@ -516,11 +521,7 @@
*/
public function key()
{
- if (null === $this->results)
- {
- $this->results = $this->getResults();
- $this->resultsCounter = count($this->results);
- }
+ $this->initResultsIfRequired();
return key($this->results);
}
@@ -532,11 +533,7 @@
*/
public function next()
{
- if (null === $this->results)
- {
- $this->results = $this->getResults();
- $this->resultsCounter = count($this->results);
- }
+ $this->initResultsIfRequired();
--$this->resultsCounter;
@@ -550,12 +547,10 @@
*/
public function rewind()
{
- if (null === $this->results)
- {
- $this->results = $this->getResults();
- $this->resultsCounter = count($this->results);
- }
+ $this->initResultsIfRequired();
+ $this->resultsCounter = count($this->results);
+
return reset($this->results);
}
@@ -566,11 +561,7 @@
*/
public function valid()
{
- if (null === $this->results)
- {
- $this->results = $this->getResults();
- $this->resultsCounter = count($this->results);
- }
+ $this->initResultsIfRequired();
return $this->resultsCounter > 0;
}
Modified: branches/1.4/lib/addon/sfPager.class.php
===================================================================
--- branches/1.4/lib/addon/sfPager.class.php 2010-02-05 21:22:59 UTC (rev
27611)
+++ branches/1.4/lib/addon/sfPager.class.php 2010-02-05 23:42:30 UTC (rev
27612)
@@ -493,6 +493,15 @@
$this->parameterHolder->set($name, $value);
}
+ protected function initResultsIfRequired()
+ {
+ if (null === $this->results)
+ {
+ $this->results = $this->getResults();
+ $this->resultsCounter = count($this->results);
+ }
+ }
+
/**
* Returns the current result.
*
@@ -500,11 +509,7 @@
*/
public function current()
{
- if (null === $this->results)
- {
- $this->results = $this->getResults();
- $this->resultsCounter = count($this->results);
- }
+ $this->initResultsIfRequired();
return current($this->results);
}
@@ -516,11 +521,7 @@
*/
public function key()
{
- if (null === $this->results)
- {
- $this->results = $this->getResults();
- $this->resultsCounter = count($this->results);
- }
+ $this->initResultsIfRequired();
return key($this->results);
}
@@ -532,11 +533,7 @@
*/
public function next()
{
- if (null === $this->results)
- {
- $this->results = $this->getResults();
- $this->resultsCounter = count($this->results);
- }
+ $this->initResultsIfRequired();
--$this->resultsCounter;
@@ -550,12 +547,10 @@
*/
public function rewind()
{
- if (null === $this->results)
- {
- $this->results = $this->getResults();
- $this->resultsCounter = count($this->results);
- }
+ $this->initResultsIfRequired();
+ $this->resultsCounter = count($this->results);
+
return reset($this->results);
}
@@ -566,11 +561,7 @@
*/
public function valid()
{
- if (null === $this->results)
- {
- $this->results = $this->getResults();
- $this->resultsCounter = count($this->results);
- }
+ $this->initResultsIfRequired();
return $this->resultsCounter > 0;
}
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.