You are here

public function ctools_context::is_type in Chaos Tool Suite (ctools) 7

Same name and namespace in other branches
  1. 6 includes/context.inc \ctools_context::is_type()

Determine whether this object is of type Both the internal value ($this->type) and the supplied value ($type) can be a string or an array of strings, and if one or both are arrays the match succeeds if at least one common element is found.

Type names

Parameters

string|array $type: 'type' can be:

  • 'any' to match all types (this is true of the internal value too).
  • an array of type name strings, when more than one type is acceptable.

Return value

bool True if the type matches, False otherwise.

File

includes/context.inc, line 126
Contains code related to the ctools system of 'context'.

Class

ctools_context
The context object is largely a wrapper around some other object, with an interface to finding out what is contained and getting to both the object and information about the object.

Code

public function is_type($type) {
  if ($type === 'any' || $this->type === 'any') {
    return TRUE;
  }
  $a = is_array($type) ? $type : array(
    $type,
  );
  $b = is_array($this->type) ? $this->type : array(
    $this->type,
  );
  return (bool) array_intersect($a, $b);
}