Created
September 23, 2016 10:52
-
-
Save lozcalver/bf1ea91fd49d8b7248743dab17c7ac5a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class CustomIteratorSupport implements TemplateIteratorProvider { | |
protected $iteratorPos; | |
protected $iteratorTotalItems; | |
/** | |
* Set the current iterator properties - where we are on the iterator. | |
* | |
* @param int $pos position in iterator | |
* @param int $totalItems total number of items | |
*/ | |
public function iteratorProperties($pos, $totalItems) { | |
$this->iteratorPos = $pos; | |
$this->iteratorTotalItems = $totalItems; | |
} | |
/** | |
* @return array | |
*/ | |
public static function get_template_iterator_variables() { | |
return array('MultiplyPos'); | |
} | |
/** | |
* Return the numerical position of this object in the container set, multiplied by the given amount | |
* | |
* @param int $startIndex Number to start count from. | |
* @param int $multiple Number to multiply the position by | |
* @return int | |
*/ | |
public function MultiplyPos($startIndex = 1, $multiple = 1) { | |
return ($this->iteratorPos + $startIndex) * $multiple; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment