Skip to content

Commit

Permalink
Throw exceptions in case that $definition['class'] is not a class of …
Browse files Browse the repository at this point in the history
…the expected type.
  • Loading branch information
donquixote committed May 23, 2014
1 parent fd30a64 commit da6ffcf
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions core/lib/Drupal/Core/Field/FieldDefinition.php
Expand Up @@ -475,7 +475,16 @@ public function getSchema() {
if (!isset($this->schema)) {
// Get the schema from the field item class.
$definition = \Drupal::service('plugin.manager.field.field_type')->getDefinition($this->getType());
if (!isset($definition['class'])) {
throw new \Exception("\$definition['class'] is not set.");
}
$class = $definition['class'];
if (!class_exists($class)) {
throw new \Exception(var_export($class, TRUE) . " is not a class.");
}
if (!is_subclass_of($class, 'Drupal\Core\Field\FieldItemInterface')) {
throw new \Exception("class $class must implement FieldItemInterface.");
}
$schema = $class::schema($this);
// Fill in default values.
$schema += array(
Expand Down

0 comments on commit da6ffcf

Please sign in to comment.