protected function FieldModifier::getBaseInfo in Realistic Dummy Content 8
Helper function, returns the original class and attribute type from type and name.
Parameters
$type: Either 'property' or 'field_config'
$name: Name of the property or field, for example 'nid', 'body', 'picture', 'title', 'field_image'.
Return value
Associative array with: original_class => string, corresponds to the fully qualified (with namespace) class name of the class which should manipulate this type of attribute. For example, any fields are manipulate by a "value field" manipulator, and and any properties (titles, created) are manipulated by a text property manipulator. Certain fields are complex, though, so this module provides an alter hook (see hook_realistic_dummy_content_attribute_manipulator_alter()). attribute_type => string, corresponds the type of attribute with which we are dealing, for example text_with_summary, title...
Throws
1 call to FieldModifier::getBaseInfo()
- FieldModifier::AddModifier in api/
src/ manipulators/ FieldModifier.php - Adds a modifier to a list of attribute modifiers.
File
- api/
src/ manipulators/ FieldModifier.php, line 115 - Define autoload class.
Class
- FieldModifier
- Field modifier class.
Namespace
Drupal\realistic_dummy_content_api\manipulatorsCode
protected function getBaseInfo($type, $name) {
$full_name = $this
->getType() . '.' . $this
->getBundle() . '.' . $name;
$field_info = entity_load('field_config', $full_name);
if (!$field_info) {
// if an field cannot be loaded, then it is a property
$type = 'property';
}
switch ($type) {
case 'property':
$original_class = '\\Drupal\\realistic_dummy_content_api\\attributes\\TextProperty';
$attribute_type = $name;
break;
case 'field_config':
$original_class = '\\Drupal\\realistic_dummy_content_api\\attributes\\ValueField';
$field_info = entity_load('field_config', $full_name);
if (!$field_info) {
throw new Exception('Unable to load field_config entity named ' . $full_name);
}
$attribute_type = $field_info
->getType();
break;
default:
throw new Exception('Please use the type property or field_config');
break;
}
$return = array(
'original_class' => $original_class,
'attribute_type' => $attribute_type,
);
return $return;
}