map_route_planner-1.0.0-alpha4/map_route_planner.module
map_route_planner.module
<?php
/**
* @file
* Provides a map route entity type.
*/
use Drupal\Core\Render\Element;
use Drupal\Core\StringTranslation\TranslatableMarkup;
/**
* Implements hook_theme().
*/
function map_route_planner_theme() {
return [
'map_route' => [
'render element' => 'elements',
],
];
}
/**
* Prepares variables for map route templates.
*
* Default template: map-route.html.twig.
*
* @param array $variables
* An associative array containing:
* - elements: An associative array containing the map route information and any
* fields attached to the entity.
* - attributes: HTML attributes for the containing element.
*/
function template_preprocess_map_route(array &$variables) {
foreach (Element::children($variables['elements']) as $key) {
$variables['content'][$key] = $variables['elements'][$key];
}
}
/**
* Implements hook_menu_links_discovered_alter().
*
* Rewrites the menu entries for map_route_planner module that relate to the configuration
* of text editors.
*/
function map_route_planner_menu_links_discovered_alter(array &$links) {
$links['entity.map_route.collection']['title'] = new TranslatableMarkup(
'Map route'
);
$links['entity.map_route.collection']['description'] = new TranslatableMarkup(
'Find and manage map route.'
);
}
function map_route_planner_library_info_alter(array &$libraries, $module) {
if ('map_route_planner' === $module && !empty($libraries['google_map'])) {
$apiKey = \Drupal::service('google_maps.factory')->getApiKey();
$libraries['google_map']['js'] = [
'js/google_map.js' => [
'weight' => -15,
],
'https://maps.googleapis.com/maps/api/js?key='.$apiKey.'&callback=initMap&libraries=places&v=weekly' => [
'type' => 'external',
'weight' => -10,
'attributes' => [
'defer' => true,
'async' => true
],
],
];
}
}
function map_route_planner_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
$toto = '2';
}
