You are here

function openlayers_layer_definition_check in Openlayers 7.2

Check the plugin definition of a layer. Some field *MUST* be there to work correctly with OL.

Parameters

$definition:

Return value

bool

1 string reference to 'openlayers_layer_definition_check'
openlayers_layer_types in ./openlayers.module
Get all layer types.

File

./openlayers.module, line 478
Main OpenLayers API File

Code

function openlayers_layer_definition_check($definition) {
  $mandatory_fields = array(
    array(
      'title',
    ),
    array(
      'description',
    ),
    array(
      'name',
    ),
    array(
      'path',
    ),
    array(
      'layer_type',
      'file',
    ),
    array(
      'layer_type',
      'class',
    ),
    array(
      'layer_type',
      'parent',
    ),
  );
  foreach ($mandatory_fields as $field) {
    $missing = drupal_array_nested_key_exists($definition, $field);
    if (!$missing) {
      drupal_set_message(t("Key !key is missing in in the plugin definition of the layer type <em>!type</em>. The layer will be disabled.", array(
        '!key' => htmlspecialchars(implode(', ', $field)),
        '!type' => htmlspecialchars($definition['name']),
      )), 'warning');
      watchdog('openlayers', 'Layer !layer is unavailable because its
                                plugin definition is incomplete.', array(
        '!layer' => $definition['name'],
      ), WATCHDOG_ERROR);
      return FALSE;
    }
  }
  return TRUE;
}