/** * Adds a Loop to the stack * * @param Loop $stackItem */ protected static function addLoopStack(Loop $stackItem) { // Check stack for parent loop to register it with this loop if (count(static::$stack) > 0) { $stackItem->setParentLoop(last(static::$stack)); } array_push(static::$stack, $stackItem); }
/** * Creates a new loop with the given array and adds it to the stack * * @param array $items The array that will be iterated * @return Loop */ public function newLoop($items) { $loop = new Loop($items); // Check stack for parent loop to register it with this loop if (count($this->stack) > 0) { $loop->setParentLoop(last($this->stack)); } array_push($this->stack, $loop); return $loop; }