class LogLocation in farmOS 2.x
Log location logic.
Hierarchy
- class \Drupal\farm_location\LogLocation implements LogLocationInterface
Expanded class hierarchy of LogLocation
1 string reference to 'LogLocation'
- farm_location.services.yml in modules/
core/ location/ farm_location.services.yml - modules/core/location/farm_location.services.yml
1 service uses LogLocation
- log.location in modules/
core/ location/ farm_location.services.yml - Drupal\farm_location\LogLocation
File
- modules/
core/ location/ src/ LogLocation.php, line 10
Namespace
Drupal\farm_locationView source
class LogLocation implements LogLocationInterface {
/**
* The name of the log location field.
*
* @var string
*/
const LOG_FIELD_LOCATION = 'location';
/**
* The name of the log geometry field.
*
* @var string
*/
const LOG_FIELD_GEOMETRY = 'geometry';
/**
* {@inheritdoc}
*/
public function hasLocation(LogInterface $log) : bool {
return !$log
->get(static::LOG_FIELD_LOCATION)
->isEmpty();
}
/**
* {@inheritdoc}
*/
public function hasGeometry(LogInterface $log) : bool {
return !$log
->get(static::LOG_FIELD_GEOMETRY)
->isEmpty();
}
/**
* {@inheritdoc}
*/
public function getLocation(LogInterface $log) : array {
return $log->{static::LOG_FIELD_LOCATION}
->referencedEntities() ?? [];
}
/**
* {@inheritdoc}
*/
public function getGeometry(LogInterface $log) : string {
return $log
->get(static::LOG_FIELD_GEOMETRY)->value ?? '';
}
/**
* {@inheritdoc}
*/
public function setLocation(LogInterface $log, array $assets) : void {
foreach ($assets as $asset) {
$log->{static::LOG_FIELD_LOCATION}[] = [
'target_id' => $asset
->id(),
];
}
}
/**
* {@inheritdoc}
*/
public function setGeometry(LogInterface $log, string $wkt) : void {
$log->{static::LOG_FIELD_GEOMETRY}->value = $wkt;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
LogLocation:: |
public | function |
Get a log's geometry. Overrides LogLocationInterface:: |
|
LogLocation:: |
public | function |
Get location assets referenced by a log. Overrides LogLocationInterface:: |
|
LogLocation:: |
public | function |
Check if a log has geometry. Overrides LogLocationInterface:: |
|
LogLocation:: |
public | function |
Check if a log references location assets. Overrides LogLocationInterface:: |
|
LogLocation:: |
constant | The name of the log geometry field. | ||
LogLocation:: |
constant | The name of the log location field. | ||
LogLocation:: |
public | function |
Set a log's geometry. Overrides LogLocationInterface:: |
|
LogLocation:: |
public | function |
Set a log's location. Overrides LogLocationInterface:: |