You are here

function _social_tagging_node_form_defaults_values in Open Social 8.6

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_tagging/social_tagging.module \_social_tagging_node_form_defaults_values()
  2. 8 modules/social_features/social_tagging/social_tagging.module \_social_tagging_node_form_defaults_values()
  3. 8.2 modules/social_features/social_tagging/social_tagging.module \_social_tagging_node_form_defaults_values()
  4. 8.3 modules/social_features/social_tagging/social_tagging.module \_social_tagging_node_form_defaults_values()
  5. 8.4 modules/social_features/social_tagging/social_tagging.module \_social_tagging_node_form_defaults_values()
  6. 8.5 modules/social_features/social_tagging/social_tagging.module \_social_tagging_node_form_defaults_values()
  7. 8.7 modules/social_features/social_tagging/social_tagging.module \_social_tagging_node_form_defaults_values()
  8. 8.8 modules/social_features/social_tagging/social_tagging.module \_social_tagging_node_form_defaults_values()
  9. 10.3.x modules/social_features/social_tagging/social_tagging.module \_social_tagging_node_form_defaults_values()
  10. 10.0.x modules/social_features/social_tagging/social_tagging.module \_social_tagging_node_form_defaults_values()
  11. 10.1.x modules/social_features/social_tagging/social_tagging.module \_social_tagging_node_form_defaults_values()
  12. 10.2.x modules/social_features/social_tagging/social_tagging.module \_social_tagging_node_form_defaults_values()

Helper function to get the current default tagging values of a node.

1 call to _social_tagging_node_form_defaults_values()
social_tagging_form_alter in modules/social_features/social_tagging/social_tagging.module
Implements hook_form_alter().

File

modules/social_features/social_tagging/social_tagging.module, line 223
Contains social_tagging.module.

Code

function _social_tagging_node_form_defaults_values(EntityInterface $entity) {

  // Init.
  $default_value = [];

  // If the node exists, we need to get the default value.
  if ($entity instanceof EntityInterface && $entity
    ->id() !== NULL) {
    foreach ($entity
      ->get('social_tagging')
      ->getValue() as $key => $value) {
      if (isset($value['target_id'])) {
        $default_value[] = $value['target_id'];
      }
    }
  }
  return $default_value;
}