Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function postBuild(array &$build, ObjectInterface $context = NULL)
 {
     parent::postBuild($build, $context);
     $options = array();
     foreach (\Drupal\openlayers\Openlayers::loadAllExportable('Map') as $machine_name => $data) {
         if (!is_object($data) || property_exists($data, 'disabled') && ($data->disabled == 1 || $data->disabled == TRUE)) {
             continue;
         }
         $options[$machine_name] = $data->name;
     }
     $wrapper = 'wrapper-' . $context->getId();
     $build['openlayers_default_map'] = array('#type' => 'select', '#title' => 'Chose a map', '#multiple' => FALSE, '#options' => $options, '#ajax' => array('callback' => '_openlayers_ajax_reload_default_map', 'method' => 'replace', 'wrapper' => $wrapper, 'effect' => 'fade'));
     $build['form'] = array('#type' => 'container', '#attributes' => array('id' => $wrapper));
     $build['form'][$context->getId()]['map'] = $build['openlayers'];
     unset($build['openlayers']);
 }