getOwningPlugin(); if(!isset($this->metadataMap[$key])){ $entry = new \SplObjectStorage(); $this->metadataMap[$key] = $entry; }else{ $entry = $this->metadataMap[$key]; } $entry[$owningPlugin] = $newMetadataValue; } /** * Returns all metadata values attached to an object. If multiple * have attached metadata, each will value will be included. * * @param string $key * * @return MetadataValue[] */ protected function getMetadataInternal(string $key){ if(isset($this->metadataMap[$key])){ return $this->metadataMap[$key]; }else{ return []; } } /** * Tests to see if a metadata attribute has been set on an object. * * @param string $key * * @return bool */ protected function hasMetadataInternal(string $key) : bool{ return isset($this->metadataMap[$key]); } /** * Removes a metadata item owned by a plugin from a subject. * * @param string $key * @param Plugin $owningPlugin */ protected function removeMetadataInternal(string $key, Plugin $owningPlugin){ if(isset($this->metadataMap[$key])){ unset($this->metadataMap[$key][$owningPlugin]); if($this->metadataMap[$key]->count() === 0){ unset($this->metadataMap[$key]); } } } /** * Invalidates all metadata in the metadata store that originates from the * given plugin. Doing this will force each invalidated metadata item to * be recalculated the next time it is accessed. * * @param Plugin $owningPlugin */ public function invalidateAll(Plugin $owningPlugin){ /** @var MetadataValue[] $values */ foreach($this->metadataMap as $values){ if(isset($values[$owningPlugin])){ $values[$owningPlugin]->invalidate(); } } } }