GeolocationComputed.php in Geolocation Field 8.2
File
src/TypedData/GeolocationComputed.php
View source
<?php
namespace Drupal\geolocation\TypedData;
use Drupal\Core\TypedData\TypedData;
use Drupal\Core\DependencyInjection\DependencySerializationTrait;
class GeolocationComputed extends TypedData {
use DependencySerializationTrait;
protected $value = NULL;
public function getValue() {
if ($this->value !== NULL) {
return $this->value;
}
$item = $this
->getParent();
if ($item) {
$lat = trim($item
->get('lat')
->getValue());
$lng = trim($item
->get('lng')
->getValue());
if ($lat !== NULL && $lng !== NULL) {
$this->value = $lat . ', ' . $lng;
}
}
return $this->value;
}
public function setValue($value, $notify = TRUE) {
$this->value = $value;
if ($notify && isset($this->parent)) {
$this->parent
->onChange($this->name);
}
}
}