You are here

protected function GetImageSize::validateKey in File metadata manager 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/FileMetadata/GetImageSize.php \Drupal\file_mdm\Plugin\FileMetadata\GetImageSize::validateKey()

Validates a file metadata key.

Return value

bool TRUE if the key is valid.

Throws

\Drupal\file_mdm\FileMetadataException In case the key is invalid.

3 calls to GetImageSize::validateKey()
GetImageSize::doGetMetadata in src/Plugin/FileMetadata/GetImageSize.php
Gets a metadata element.
GetImageSize::doRemoveMetadata in src/Plugin/FileMetadata/GetImageSize.php
Removes a metadata element.
GetImageSize::doSetMetadata in src/Plugin/FileMetadata/GetImageSize.php
Sets a metadata element.

File

src/Plugin/FileMetadata/GetImageSize.php, line 46

Class

GetImageSize
FileMetadata plugin for getimagesize.

Namespace

Drupal\file_mdm\Plugin\FileMetadata

Code

protected function validateKey($key, $method) {
  if (!is_int($key) && !is_string($key)) {
    throw new FileMetadataException("Invalid metadata key specified", $this
      ->getPluginId(), $method);
  }
  if (!in_array($key, $this
    ->getSupportedKeys(), TRUE)) {
    throw new FileMetadataException("Invalid metadata key '{$key}' specified", $this
      ->getPluginId(), $method);
  }
  return TRUE;
}