Skip to content

Instantly share code, notes, and snippets.

@dypsilon
Created June 4, 2011 23:57
Show Gist options
  • Select an option

  • Save dypsilon/1008507 to your computer and use it in GitHub Desktop.

Select an option

Save dypsilon/1008507 to your computer and use it in GitHub Desktop.
Guard Clause
<?php
public function markActiveNode($navigation, $currentUrl)
{
if(!empty($navigation['nodes']) && is_array($navigation['nodes']) {
foreach ($navigation['nodes'] as $node) {
$node['isActive'] = false;
if(!empty($node['url'])) {
if($node['isVisible']) {
$node['isActive'] = ($node['url'] === $currentUrl);
}
}
}
}
return $navigation;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment