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.
Each context object has its own information, but some things are very common, such as titles, data, keywords, etc. In particulare, the 'type' of the context is important.
Hierarchy
- class \ctools_context
Expanded class hierarchy of ctools_context
3 string references to 'ctools_context'
- ctools_access_menu in ./
ctools.module - Determine if the current user has access via a plugin.
- page_manager_page_execute in page_manager/
plugins/ tasks/ page.inc - Execute a page task.
- views_content_plugin_display_ctools_context::option_definition in views_content/
plugins/ views/ views_content_plugin_display_ctools_context.inc - Information about options for all kinds of purposes will be held here.
File
-
includes/
context.inc, line 29
View source
class ctools_context {
/**
* @var string|array
* A string naming this specific context type. The values 'any' and 'none'
* are special:
* - 'any': used in is_type() to match any other type.
* - 'none': used to signal the type is not defined.
*/
public $type;
/**
* @var mixed
* The data payload for this context object.
*/
public $data;
/**
* @var string
* The title of this object.
*/
public $title;
/**
* @var string
* The title of the page if this object exists
*/
public $page_title;
/**
* @var string
* The identifier (in the UI) of this object.
*/
public $identifier;
/**
* @var
*/
public $argument;
/**
* @var string
*/
public $keyword;
/**
* @var
*/
public $original_argument;
/**
* @var
*/
public $id;
/**
* @var
*/
public $plugin;
/**
* @var array
*/
public $restrictions;
/**
* @var bool
*/
public $empty;
/**
* The ctools_context constructor.
*
* @param string $type
* The type name of this context. Should be unique. Use the machine_name
* conventions: lowercase, short, underscores and no spaces.
* @param mixed $data
* The data payload, if required for this context.
*/
public function __construct($type = 'none', $data = NULL) {
$this->type = $type;
$this->data = $data;
$this->title = t('Unknown context');
$this->page_title = '';
$this->identifier = '';
$this->keyword = '';
$this->restrictions = array();
$this->empty = FALSE;
// Other vars are NULL.
}
/**
* Determine whether this object is of type @var $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
*
* @param 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 bool
* True if the type matches, False otherwise.
*/
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);
}
/**
* Return the argument.
*
* @return mixed
* The value of $argument.
*/
public function get_argument() {
return $this->argument;
}
/**
* Return the value of argument (or arg) variable as it was passed in.
*
* For example see ctools_plugin_load_function() and ctools_terms_context().
*
* @return mixed
* The original arg value.
*/
public function get_original_argument() {
if (!is_null($this->original_argument)) {
return $this->original_argument;
}
return $this->argument;
}
/**
* Return the keyword.
*
* @return mixed
* The value of $keyword.
*/
public function get_keyword() {
return $this->keyword;
}
/**
* Return the identifier.
*
* @return mixed
* The value of $identifier.
*/
public function get_identifier() {
return $this->identifier;
}
/**
* Return the title.
*
* @return mixed
* The value of $title.
*/
public function get_title() {
return $this->title;
}
/**
* Return the page title.
*
* @return mixed
* The value of $page_title.
*/
public function get_page_title() {
return $this->page_title;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
ctools_context::$argument | public | property | @var |
ctools_context::$data | public | property | The data payload for this context object. |
ctools_context::$empty | public | property | |
ctools_context::$id | public | property | @var |
ctools_context::$identifier | public | property | The identifier (in the UI) of this object. |
ctools_context::$keyword | public | property | |
ctools_context::$original_argument | public | property | @var |
ctools_context::$page_title | public | property | The title of the page if this object exists |
ctools_context::$plugin | public | property | @var |
ctools_context::$restrictions | public | property | |
ctools_context::$title | public | property | The title of this object. |
ctools_context::$type | public | property | A string naming this specific context type. The values 'any' and 'none' are special: |
ctools_context::get_argument | public | function | Return the argument. |
ctools_context::get_identifier | public | function | Return the identifier. |
ctools_context::get_keyword | public | function | Return the keyword. |
ctools_context::get_original_argument | public | function | Return the value of argument (or arg) variable as it was passed in. |
ctools_context::get_page_title | public | function | Return the page title. |
ctools_context::get_title | public | function | Return the title. |
ctools_context::is_type | public | function | 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. |
ctools_context::__construct | public | function | The ctools_context constructor. |