class context_condition_entity_view_mode in Context entity field 7
Expose entity view mode as a context condition.
Hierarchy
- class \context_condition
Expanded class hierarchy of context_condition_entity_view_mode
2 string references to 'context_condition_entity_view_mode'
- context_entity_field_context_plugins in ./
context_entity_field.module - Implements hook_context_plugins().
- context_entity_field_context_registry in ./
context_entity_field.module - Implements hook_context_registry().
File
- plugins/
context_condition_entity_view_mode.inc, line 11 - Implement context condiction class for entity view mode.
View source
class context_condition_entity_view_mode extends context_condition {
/**
* Omit condition values. We will provide a custom input form for our conditions.
*/
public function condition_values() {
return array();
}
/**
* Condition form.
*/
public function condition_form($context) {
$form = array();
$defaults = $this
->fetch_from_context($context, 'values');
$entity_types = array();
foreach (entity_get_info() as $entity_type_name => $entity_type) {
foreach ($entity_type['view modes'] as $view_mode => $value) {
$entity_types[$entity_type_name . '|' . $view_mode] = $entity_type['label'] . ' - ' . $value['label'];
}
}
$form['entity_type'] = array(
'#title' => t('Entity type'),
'#type' => 'checkboxes',
'#options' => $entity_types,
'#description' => t('Select entity type to check'),
'#default_value' => isset($defaults['entity_type']) ? unserialize($defaults['entity_type']) : array(),
);
return $form;
}
/**
* Condition form submit handler.
*/
public function condition_form_submit($values) {
return array(
'entity_type' => serialize($values['entity_type']),
);
}
/**
* Execute.
*/
public function execute($entity_type, $view_mode) {
if ($this
->condition_used()) {
foreach ($this
->get_contexts() as $context) {
$settings = $this
->fetch_from_context($context, 'values');
if (in_array("{$entity_type}|{$view_mode}", array_filter(unserialize($settings['entity_type'])))) {
$this
->condition_met($context);
}
}
}
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
context_condition:: |
property | |||
context_condition:: |
property | |||
context_condition:: |
property | |||
context_condition:: |
property | |||
context_condition:: |
function | Marks a context as having met this particular condition. | ||
context_condition:: |
function | Check whether this condition is used by any contexts. Can be used to prevent expensive condition checks from being triggered when no contexts use this condition. | ||
context_condition:: |
function | Context editor form for conditions. | 2 | |
context_condition:: |
function | Context editor form submit handler. | ||
context_condition:: |
function | Retrieve options from the context provided. | ||
context_condition:: |
function | Retrieve all contexts with the condition value provided. | 2 | |
context_condition:: |
function | Options form. Provide additional options for your condition. | 4 | |
context_condition:: |
function | Options form submit handler. | ||
context_condition:: |
function | Settings form. Provide variable settings for your condition. | ||
context_condition:: |
function | Clone our references when we're being cloned. | ||
context_condition:: |
function | Constructor. Do not override. | ||
context_condition_entity_view_mode:: |
public | function |
Condition form. Overrides context_condition:: |
|
context_condition_entity_view_mode:: |
public | function |
Condition form submit handler. Overrides context_condition:: |
|
context_condition_entity_view_mode:: |
public | function |
Omit condition values. We will provide a custom input form for our conditions. Overrides context_condition:: |
|
context_condition_entity_view_mode:: |
public | function | Execute. |