Add an isLocation() method to the asset.location service.
This commit is contained in:
parent
bab926b199
commit
fda3f325ac
|
@ -13,6 +13,8 @@ determining an asset's location and geometry.
|
|||
|
||||
**Methods**:
|
||||
|
||||
`isLocation($asset)` - Check if an asset is a location. Returns a boolean.
|
||||
|
||||
`isFixed($asset)` - Check if an asset is fixed. Returns a boolean.
|
||||
|
||||
`hasLocation($asset)` - Check if an asset is located within other location
|
||||
|
|
|
@ -22,6 +22,13 @@ class AssetLocation implements AssetLocationInterface {
|
|||
*/
|
||||
const ASSET_FIELD_GEOMETRY = 'intrinsic_geometry';
|
||||
|
||||
/**
|
||||
* The name of the asset boolean location field.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const ASSET_FIELD_LOCATION = 'is_location';
|
||||
|
||||
/**
|
||||
* The name of the asset boolean fixed field.
|
||||
*
|
||||
|
@ -99,6 +106,13 @@ class AssetLocation implements AssetLocationInterface {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isLocation(AssetInterface $asset): bool {
|
||||
return !empty($asset->{static::ASSET_FIELD_LOCATION}->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
@ -10,6 +10,17 @@ use Drupal\log\Entity\LogInterface;
|
|||
*/
|
||||
interface AssetLocationInterface {
|
||||
|
||||
/**
|
||||
* Check if an asset is a location.
|
||||
*
|
||||
* @param \Drupal\asset\Entity\AssetInterface $asset
|
||||
* The Asset entity.
|
||||
*
|
||||
* @return bool
|
||||
* Returns TRUE if it is a location, FALSE otherwise.
|
||||
*/
|
||||
public function isLocation(AssetInterface $asset): bool;
|
||||
|
||||
/**
|
||||
* Check if an asset is fixed.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue