function 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 137

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);
}