public function Debug::postBuild in Openlayers 7.3
Invoked after an objects render array is built.
Mostly invoked by the map object.
Parameters
array $build: The array with the build information.
\Drupal\openlayers\Types\ObjectInterface $context: The context of the build. Mostly the map object.
Overrides Base::postBuild
File
- src/
Plugin/ Component/ Debug/ Debug.php, line 23 - Component: Debug.
Class
- Debug
- Class Debug.
Namespace
Drupal\openlayers\Plugin\Component\DebugCode
public function postBuild(array &$build, ObjectInterface $context = NULL) {
$alternative_template = 'openlayers--' . str_replace('_', '-', $context
->getMachineName()) . '.tpl.php';
$template_value = file_get_contents(drupal_get_path('module', 'openlayers') . '/theme/openlayers.tpl.php');
$build['parameters'][$this
->getPluginId()] = array(
'#type' => 'fieldset',
'#title' => 'Map debug',
'#description' => 'Here\'s a quick view of all the objects in the map.',
'#attributes' => array(
'class' => array(
'collapsible',
'collapsed',
),
),
'#attached' => array(
'library' => array(
array(
'system',
'drupal.collapse',
),
),
),
'theme' => array(
'#weight' => 20,
'#type' => 'fieldset',
'#attributes' => array(
'class' => array(
'collapsible',
'collapsed',
),
),
'#title' => 'Theming information',
'template_content' => array(
'#title' => 'Openlayers map template',
'#type' => 'textarea',
'#default_value' => $template_value,
'#value' => $template_value,
'#description' => t('The default Openlayers template is <strong>openlayers.tpl.php</strong> for all the maps. You may override it by creating a file with the same name in your theme template\'s directory. You can also name it <em>openlayers--[map_machine_name].tpl.php</em> if you want to alter the display of this particular map only. For example: <strong>@template</strong>.', array(
'@template' => $alternative_template,
)),
),
),
);
foreach ($context
->getCollection()
->getObjects() as $type => $objects) {
$build['parameters'][$this
->getPluginId()][$type] = array(
'#type' => 'fieldset',
'#title' => 'Plugin type: ' . $type,
'#attributes' => array(
'class' => array(
'collapsible',
'collapsed',
),
),
);
foreach ($objects as $object) {
$build['parameters'][$this
->getPluginId()][$type][$object
->getMachineName()] = array(
'#type' => 'fieldset',
'#attributes' => array(
'class' => array(
'collapsible',
'collapsed',
),
),
'#title' => $object
->getMachineName(),
'configuration' => $this
->getInfo($object),
);
}
}
}