Add an isLocation() method to the asset.location service.

This commit is contained in:
Michael Stenta 2021-06-04 14:47:53 -04:00
parent bab926b199
commit fda3f325ac
3 changed files with 27 additions and 0 deletions

View File

@ -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

View File

@ -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}
*/

View File

@ -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.
*