You are here

public function FlexiformElement::getCtoolsContexts in Flexiform 7

Get an array of ctools context for the flexiform.

Parameters

array $entities: An array of entities keyed by namespace. If NULL, placeholder contexts will be used.

Return value

ctools_context[] An array of ctools contexts.

3 calls to FlexiformElement::getCtoolsContexts()
FlexiformElement::getCtoolsSubstitutionsList in includes/flexiform.element.inc
Build a list of possible ctools substitutions.
FlexiformElement::replaceCtoolsSubstitutions in includes/flexiform.element.inc
Replace ctools substitutions with their values.
FlexiformElementCtoolsContent::form in includes/element/ctools_content.element.inc
Returns the custom html that is defined in the configure form.

File

includes/flexiform.element.inc, line 371
Controller class for flexiform elements.

Class

FlexiformElement
Base class for all FlexiformElements

Code

public function getCtoolsContexts($entities = array()) {
  global $user;
  ctools_include('context');
  $contexts = array(
    'global' => ctools_context_create('token'),
    'current-user' => ctools_context_create('entity:user', $user),
  );
  $contexts['global']->keyword = 'global';
  $contexts['current-user']->keyword = 'current-user';
  $contexts['current-user']->identifier = t('Logged-in user');
  foreach ($this->flexiform->entities as $namespace => $info) {
    $type = 'entity:' . $info['entity_type'];
    if (isset($entities[$namespace])) {
      $contexts[$namespace] = ctools_context_create($type, $entities[$namespace]);
    }
    else {
      $contexts[$namespace] = ctools_context_create_empty($type);
    }
    $contexts[$namespace]->keyword = $namespace;
    $contexts[$namespace]->identifier = $info['label'];
  }
  return $contexts;
}