You are here

static function RealisticDummyContent::validate_class in Realistic Dummy Content 8

Validate that a class is a valid subclasss of Base

Parameters

$class: A class name

Throws

\Exception

2 calls to RealisticDummyContent::validate_class()
RealisticDummyContent::improve_dummy_content in api/src/facade/RealisticDummyContent.php
Insert or improve dummy data in an entity of a given type.
realistic_dummy_content_api_validate_class in api/realistic_dummy_content_api.module
Validate that a class is a valid subclasss of Base

File

api/src/facade/RealisticDummyContent.php, line 134
Define autoload class.

Class

RealisticDummyContent

Namespace

Drupal\realistic_dummy_content_api\facade

Code

static function validate_class($class) {
  if (!class_exists($class)) {
    throw new \Exception(t('@class is not a valid class; make sure you include its full namespace and that it is properly defined, and that you have cleared your cache.', array(
      '@class' => $class,
    )));
  }
  if (!is_subclass_of($class, '\\Drupal\\realistic_dummy_content_api\\manipulators\\Base')) {
    throw new \Exception(t('@class is a valid class but it is not a subclass of \\Drupal\\realistic_dummy_content_api\\manipulators\\Base.', array(
      '@class' => $class,
    )));
  }
}