public function ctools_context_required::__construct in Chaos Tool Suite (ctools) 7
The ctools_context_required constructor.
Note: Constructor accepts a variable number of arguments, with optional type-dependent args at the end of the list and one required argument, the title. Note in particular that skip_name_check MUST be passed in as a boolean (and not, for example, as an integer).
Parameters
string $title: The title of the context for use in UI selectors when multiple contexts qualify.
string $keywords: One or more keywords to use for matching which contexts are allowed.
array $restrictions: Array of context restrictions.
bool $skip_name_check: If True, skip the check in select() for contexts whose names may have changed.
File
- includes/
context.inc, line 251 - Contains code related to the ctools system of 'context'.
Class
- ctools_context_required
- Used to create a method of comparing if a list of contexts match a required context type.
Code
public function __construct($title) {
// If it was possible, using variadic syntax this should be:
// __construct($title, string ...$keywords, array $restrictions = NULL, bool $skip = NULL)
// but that form isn't allowed.
$args = func_get_args();
$this->title = array_shift($args);
// If we have a boolean value at the end for $skip_name_check, store it.
if (is_bool(end($args))) {
$this->skip_name_check = array_pop($args);
}
// If we were given restrictions at the end, store them.
if (count($args) > 1 && is_array(end($args))) {
$this->restrictions = array_pop($args);
}
if (count($args) === 1) {
$args = array_shift($args);
}
$this->keywords = $args;
}