You are here

function hook_realistic_dummy_content_attribute_manipulator_alter in Realistic Dummy Content 8

Same name and namespace in other branches
  1. 8.2 api/realistic_dummy_content_api.api.php \hook_realistic_dummy_content_attribute_manipulator_alter()
  2. 7.2 api/realistic_dummy_content_api.api.php \hook_realistic_dummy_content_attribute_manipulator_alter()
  3. 7 api/realistic_dummy_content_api.api.php \hook_realistic_dummy_content_attribute_manipulator_alter()
  4. 3.x api/realistic_dummy_content_api.api.php \hook_realistic_dummy_content_attribute_manipulator_alter()

Parameters

&$class: The original class name, fully qualified with its namespace, which is set to manipulate attributes of this type. For example, if the machine name of a field type is text_with_summary, because this is a field, Realistic Dummy Content will use the field manipulator by default, however, that is not enough to manipulate this field which is more complex (contains a summary, text format...) so another class will be used instead. If you are a developer, your module can define which class manipulates fields of given types. See the TextWithSummaryField class, included with this module, for an example.

&$machine_name: The machine name of the field or property, for example "title", "text_with_summary", or "picture".

1 function implements hook_realistic_dummy_content_attribute_manipulator_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

realistic_dummy_content_api_realistic_dummy_content_attribute_manipulator_alter in api/realistic_dummy_content_api.module
Implements hook_realistic_dummy_content_attribute_manipulator_alter().
1 invocation of hook_realistic_dummy_content_attribute_manipulator_alter()
FieldModifier::AddModifier in api/src/manipulators/FieldModifier.php
Adds a modifier to a list of attribute modifiers.

File

api/realistic_dummy_content_api.api.php, line 23
Hook definitions. These functions are never called, and are included here for documentation purposes only.

Code

function hook_realistic_dummy_content_attribute_manipulator_alter(&$class, &$type, &$machine_name) {

  // If you want to implement a particular manipulator class for a field or property
  // you can do so by implementing this hook and reproducing what's below for your
  // own field or property type.
  switch ($machine_name) {
    case 'picture':

      // the user picture
      $class = 'Drupal\\realistic_dummy_content_api\\attributes\\UserPicture';
      break;
    case 'text_with_summary':

      // e.g. body
      $class = 'Drupal\\realistic_dummy_content_api\\attributes\\TextWithSummaryField';
      break;
    case 'taxonomy_term_reference':

      // e.g. tags on articles
      $class = 'Drupal\\realistic_dummy_content_api\\attributes\\TermReferenceField';
      break;
    case 'image':

      // e.g. images on articles
      $class = 'Drupal\\realistic_dummy_content_api\\attributes\\ImageField';
      break;
    default:
      break;
  }
}