public function YoastSeoFieldManager::addSnippetEditorMarkup in Real-time SEO for Drupal 8
Add code for snippet.
Parameters
array $form: Form.
Return value
array Form.
File
- src/
YoastSeoFieldManager.php, line 308
Class
- YoastSeoFieldManager
- Class YoastSeoFieldManager.
Namespace
Drupal\yoast_seoCode
public function addSnippetEditorMarkup($form) {
$yoast_settings = $form['#yoast_settings'];
$body_field = isset($yoast_settings['body']) ? $yoast_settings['body'] : '';
$yoast_seo_manager = \Drupal::service('yoast_seo.manager');
$output = $yoast_seo_manager
->getSnippetEditorMarkup();
$body_weight = isset($form[$body_field]['#weight']) ? $form[$body_field]['#weight'] : 20;
// Add rendered template to the form, where we want the snippet.
$this
->formSet($form, 'field_yoast_seo.widget.0.yoast_seo.snippet_analysis', [
'#weight' => $body_weight + 1,
'#markup' => $output,
'#parents' => [],
]);
return $form;
}