You are here

function MessagesAlter::contains in Custom Submit Messages 7.x

Same name and namespace in other branches
  1. 7 messages_alter/lib/MessagesAlter.7.x-1.3.php \MessagesAlter::contains()

An easy way to search the messages for a string

Parameters

$search: A string to search for

$type: The type of message you're searching

Return value

ARRAY if the messages contains the string FALSE when no string exists

File

messages_alter/lib/MessagesAlter.6.x-1.3.php, line 134
Contains the MessagesAlter class

Class

MessagesAlter
Defines the MessagesAlter class.

Code

function contains($search, $type = 'all') {
  $matches = array();
  $has_match = FALSE;
  $types = $this
    ->getTypes($type);
  foreach ($types as $t) {
    if ($match = $this
      ->containsByType($t, $search)) {
      $matches[$t] = $match;
      $has_match = TRUE;
    }
  }
  return $has_match ? $matches : FALSE;
}