<?php

namespace Drupal\pano_maps\Plugin\Block;

use Drupal\Core\Block\BlockBase;

/**
 * Provides a block for showing panoramic map of network.
 *
 * @Block(
 *   id = "pano_maps_network_block",
 *   admin_label = @Translation("Panoramic map of Network"),
 * )
 */
class PanoMapsNetworkBlock extends BlockBase {

  /**
   * {@inheritdoc}
   */
  public function label():string {
    return "Panoramic map of Network";
  }

  /**
   * {@inheritdoc}
   */
  public function build():array {

    $module_handler = \Drupal::service('module_handler');
    $module_path = $module_handler->getModule('pano_maps')->getPath();

    return [
      '#attached' => [
        'library' => [
          'pano_maps/network_map',
        ],
        'drupalSettings' => [
          'pano_maps' => [
            'path' => $module_path,
          ],
        ],
      ],
      '#theme' => 'pano_maps',
      '#element' => [],
    ];
  }

}
