public function NormalizerBase::supportsDenormalization

Implements \Symfony\Component\Serializer\Normalizer\DenormalizerInterface::supportsDenormalization()

Overrides DenormalizerInterface::supportsDenormalization

File

drupal/core/modules/hal/lib/Drupal/hal/Normalizer/NormalizerBase.php, line 50
Contains \Drupal\hal\Normalizer\NormalizerBase.

Class

NormalizerBase
Base class for Normalizers.

Namespace

Drupal\hal\Normalizer

Code

public function supportsDenormalization($data, $type, $format = NULL) {
  if (in_array($format, $this->formats)) {
    $target = new \ReflectionClass($type);
    $supported = new \ReflectionClass($this->supportedInterfaceOrClass);
    if ($supported
      ->isInterface()) {
      return $target
        ->implementsInterface($this->supportedInterfaceOrClass);
    }
    else {
      return $target
        ->getName() == $this->supportedInterfaceOrClass || $target
        ->isSubclassOf($this->supportedInterfaceOrClass);
    }
  }
}