registerArgument('for', 'string', 'path in Menu.yaml', false); $this->registerArgument('as', 'string', 'Name in Frontend', false); $this->registerArgument('links', 'array', 'links to show', true); $this->registerArgument('activeStep', 'int', 'current active link index', false, 1); $this->registerArgument('returnable', 'bool', 'can you go back to the last index', false, true); $this->registerArgument('stepsAs', 'string', 'variable name of a single step', false, 'steps'); $this->registerArgument('backLinkAs', 'string', 'variable name of a backlink', false, 'backLink'); $this->registerArgument('linksAs', 'string', 'variable name of the links array', false, 'links'); $this->registerArgument( 'activeStepLinkAs', 'string', 'variable name of the active step link', false, 'activeStepLink' ); $this->registerArgument('offset', 'int', 'offset to start with', false, 1); $this->registerArgument('linkCount', 'int', 'force this number of steps', false); } /** * @return mixed */ public function render() { $links = $activeStep = $returnable = $stepsAs = $backLinkAs = $activeStepAs = $linksAs = $activeStepLinkAs = $offset = $linkCount = null; \extract($this->arguments, \EXTR_OVERWRITE); //handling famous off by one $activeStep -= $offset; //make sure our array index is numeric if (\is_iterable($links)) { $links = \iterator_to_array($links); } $links = \array_values($links); if (!$linkCount) { $linkCount = \count($links); } foreach ($links as $i => &$link) { $link['completed'] = $activeStep > $i; $link['returnable'] = $returnable && $i < $activeStep; } $this->templateVariableContainer->add($linksAs, $links); $this->templateVariableContainer->add($stepsAs, $linkCount); $this->templateVariableContainer->add($activeStepAs, $activeStep + $offset); $this->templateVariableContainer->add($activeStepLinkAs, $links[$activeStep]); if (isset($links[$activeStep - 1])) { $this->templateVariableContainer->add($backLinkAs, $links[$activeStep - 1]); } return $this->renderChildren(); } }