You are here

public function CacheDecoratedDataProvider::isInstanceOf in RESTful 7.2

Checks if the decorated object is an instance of something.

Parameters

string $class: Class or interface to check the instance.

Return value

bool TRUE if the decorated object is an instace of the $class. FALSE otherwise.

Overrides ExplorableDecoratorInterface::isInstanceOf

File

src/Plugin/resource/DataProvider/CacheDecoratedDataProvider.php, line 293
Contains \Drupal\restful\Plugin\resource\DataProvider\CacheDecoratedDataProvider.

Class

CacheDecoratedDataProvider
Class CacheDecoratedDataProvider.

Namespace

Drupal\restful\Plugin\resource\DataProvider

Code

public function isInstanceOf($class) {
  if ($this instanceof $class || $this->subject instanceof $class) {
    return TRUE;
  }

  // Check if the decorated resource is also a decorator.
  if ($this->subject instanceof ExplorableDecoratorInterface) {
    return $this->subject
      ->isInstanceOf($class);
  }
  return FALSE;
}