Add removeMetadata to StateInterface.
This commit is contained in:
@@ -459,6 +459,22 @@ final class StateEntity implements iState
|
||||
return $this->metadata[$via] ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function removeMetadata(string $backend): array
|
||||
{
|
||||
if (null === ($this->metadata[$backend] ?? null)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$metadata = $this->metadata[$backend];
|
||||
|
||||
unset($this->metadata[$backend]);
|
||||
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
|
||||
@@ -295,6 +295,15 @@ interface StateInterface extends LoggerAwareInterface
|
||||
*/
|
||||
public function getMetadata(string|null $via = null): array;
|
||||
|
||||
/**
|
||||
* Get metadata.
|
||||
*
|
||||
* @param string $backend The backend name to remove metadata from.
|
||||
*
|
||||
* @return array Return the removed metadata. Or empty array if not found.
|
||||
*/
|
||||
public function removeMetadata(string $backend): array;
|
||||
|
||||
/**
|
||||
* Set metadata related to {$this->via} backend.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user