You are here

public function VisitorGeolocation::build in Smart IP 8.3

Same name and namespace in other branches
  1. 8.4 modules/device_geolocation/src/Plugin/Block/VisitorGeolocation.php \Drupal\device_geolocation\Plugin\Block\VisitorGeolocation::build()

Builds and returns the renderable array for this block plugin.

If a block should not be rendered because it has no content, then this method must also ensure to return no content: it must then only return an empty array, or an empty array with #cache set (with cacheability metadata indicating the circumstances for it being empty).

Return value

array A renderable array representing the content of the block.

Overrides BlockPluginInterface::build

See also

\Drupal\block\BlockViewBuilder

File

modules/device_geolocation/src/Plugin/Block/VisitorGeolocation.php, line 21

Class

VisitorGeolocation
Defines Device Geolocation block plugins.

Namespace

Drupal\device_geolocation\Plugin\Block

Code

public function build() {

  /** @var \Drupal\smart_ip\SmartIpLocation $location */
  $location = \Drupal::service('smart_ip.smart_ip_location');
  $data = $location
    ->getData(FALSE);
  return [
    '#theme' => 'device_geolocation_visitor_info',
    '#location' => $data,
  ];
}