rdf_preprocess_user(&$variables)
Implements hook_preprocess_HOOK() for user templates.
File
- core/modules/rdf/rdf.module, line 360
- Enables semantically enriched output for Drupal sites in the form of RDFa.
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | function rdf_preprocess_user(& $variables ) { /** @var $account \Drupal\user\UserInterface */ $account = $variables [ 'elements' ][ '#user' ]; $uri = $account ->urlInfo(); $mapping = rdf_get_mapping( 'user' , 'user' ); $bundle_mapping = $mapping ->getPreparedBundleMapping(); // Adds RDFa markup to the user profile page. Fields displayed in this page // will automatically describe the user. if (! empty ( $bundle_mapping [ 'types' ])) { $variables [ 'attributes' ][ 'typeof' ] = $bundle_mapping [ 'types' ]; $variables [ 'attributes' ][ 'about' ] = $account ->url(); } // If we are on the user account page, add the relationship between the // sioc:UserAccount and the foaf:Person who holds the account. if (\Drupal::routeMatch()->getRouteName() == $uri ->getRouteName()) { // Adds the markup for username as language neutral literal, see // rdf_preprocess_username(). $name_mapping = $mapping ->getPreparedFieldMapping( 'name' ); if (! empty ( $name_mapping [ 'properties' ])) { $username_meta = array ( '#tag' => 'meta' , '#attributes' => array ( 'about' => $account ->url(), 'property' => $name_mapping [ 'properties' ], 'content' => $account ->getDisplayName(), 'lang' => '' , ), ); $variables [ '#attached' ][ 'html_head' ][] = [ $username_meta , 'rdf_user_username' ]; } } } |
Please login to continue.