Для получения полного доступа
зарегистрируйтесь.
RSS

All snippets tagged with "is home page" tag



SilverFire
  • Reputation: 3
  • Snippets: 1
  • Revisions: 0

The function above checks, whether the current controller's action is the same as defined in the defaultRoute property of application.

function isHomePage() {
  $actualRoute = Yii::$app->controller->getRoute();

  list($controller, $actionId) = Yii::$app->createController('');
  $actionId = !empty($actionId) ? $actionId : $controller->defaultAction;
  $defaultRoute = $controller->getUniqueId() . '/' . $actionId;

  return $actualRoute === $defaultRoute;
}