You are here

public static function RocketChat::checkIfTargetIsRocketChatPath in Rocket.Chat 7

Same name and namespace in other branches
  1. 7.2 src/RocketChat.class.inc \RocketChat\RocketChat::checkIfTargetIsRocketChatPath()

Check if path is in the config to render this element on.

Parameters

array $paths: Array of Paths to show the Widget on.

string $target: The current Path to check for.

Return value

bool True if this target should have the widget, false if not. True if this target should have the widget, false if not.

2 calls to RocketChat::checkIfTargetIsRocketChatPath()
RocketChat::hookPageAlter in ./RocketChat.class.inc
Implements hook_page_alter().
RocketChatTestUnitTest::pathTest in ./rocket_chat.test

File

./RocketChat.class.inc, line 27

Class

RocketChat
Class RocketChat.

Namespace

RocketChat

Code

public static function checkIfTargetIsRocketChatPath(array &$paths, $target) {
  if (empty($target)) {
    watchdog("Rocket.Chat", "No page restriction, showing on all pages.", array(), WATCHDOG_DEBUG);
    return TRUE;
  }
  $path = drupal_strtolower(drupal_get_path_alias($target));
  $pages = implode(PHP_EOL, $paths);

  // Compare the lowercase internal and lowercase path alias (if any).
  $page_match = drupal_match_path($path, $pages);
  if ($path != $_GET['q']) {
    $page_match = $page_match || drupal_match_path($_GET['q'], $pages);
  }
  return $page_match;
}