Skip to content

Instantly share code, notes, and snippets.

@Majkl578
Last active December 14, 2015 01:18
Show Gist options
  • Select an option

  • Save Majkl578/5004810 to your computer and use it in GitHub Desktop.

Select an option

Save Majkl578/5004810 to your computer and use it in GitHub Desktop.
<?php
/**
* @param string
* @return bool
*/
public function isModuleCurrent($module)
{
$module = trim((string) $module);
$pos = strrpos($this->getName(), ':');
$current = $pos !== FALSE ? substr($this->getName(), 0, $pos + 1) : NULL;
if ($current === NULL) {
return $module === '';
}
return Strings::startsWith($current, $module . ':');
}
Usage:
n:class="$presenter->isModuleCurrent('Backend:Dashboard') ? active"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment