Skip to content

Commit

Permalink
Simplify code.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Oct 5, 2016
1 parent 27db868 commit f9e3b56
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions src/View/Helper/BreadcrumbsHelper.php
Expand Up @@ -218,24 +218,15 @@ public function render(array $attributes = [], array $separator = [])
$crumbsCount = count($crumbs);
$templater = $this->templater();

$separatorParams = [];
if ($separator) {
if (isset($separator['innerAttrs'])) {
$separatorParams['innerAttrs'] = $templater->formatAttributes($separator['innerAttrs']);
unset($separator['innerAttrs']);
$separator['innerAttrs'] = $templater->formatAttributes($separator['innerAttrs']);
}

if (isset($separator['separator'])) {
$separatorParams['separator'] = $separator['separator'];
unset($separator['separator']);
}

if (isset($separator['templateVars'])) {
$separatorParams['templateVars'] = $separator['templateVars'];
unset($separator['templateVars']);
}

$separatorParams['attrs'] = $templater->formatAttributes($separator);
$separator['attrs'] = $templater->formatAttributes(
$separator,
['innerAttrs', 'separator']
);
}

$crumbTrail = '';
Expand Down Expand Up @@ -264,8 +255,8 @@ public function render(array $attributes = [], array $separator = [])
$template = 'itemWithoutLink';
}

if ($separatorParams && $key !== ($crumbsCount - 1)) {
$templateParams['separator'] = $this->formatTemplate('separator', $separatorParams);
if ($separator && $key !== ($crumbsCount - 1)) {
$templateParams['separator'] = $this->formatTemplate('separator', $separator);
}

$crumbTrail .= $this->formatTemplate($template, $templateParams);
Expand Down

0 comments on commit f9e3b56

Please sign in to comment.