wiki.techinc.nl/includes/media/TrivialMediaHandlerState.php
Tim Starling f5d86ec75e Replace usage of custom File properties
Some MediaHandler subclasses were setting custom properties on the File
object in order to cache file-associated state. So:

* Add File::getHandlerState() and File::setHandlerState().
* Put them in an interface, which will be used in a subsequent commit in
  MediaHandler::getSizeAndMetadata().
* Use them in DjvuHandler.
* Provide a trivial implementation of the interface, for use in testing
  and in the subsequent commit.

Change-Id: Ic365384ff13f7898c1203da38c4405abf03d7563
2021-05-27 18:48:06 +10:00

19 lines
370 B
PHP

<?php
/**
* Trivial implementation of MediaHandlerState.
*
* @since 1.37
*/
class TrivialMediaHandlerState implements MediaHandlerState {
/** @var array */
private $state = [];
public function getHandlerState( string $key ) {
return $this->state[$key] ?? null;
}
public function setHandlerState( string $key, $value ) {
$this->state[$key] = $value;
}
}