You are here

public function YoastSeoFieldManager::addOverallScoreMarkup in Real-time SEO for Drupal 8

Add Overall score markup to the form.

Parameters

array $form: The form.

Return value

mixed Modified form.

File

src/YoastSeoFieldManager.php, line 334

Class

YoastSeoFieldManager
Class YoastSeoFieldManager.

Namespace

Drupal\yoast_seo

Code

public function addOverallScoreMarkup($form, &$form_state) {
  $yoast_seo_manager = \Drupal::service('yoast_seo.manager');

  // Retrieve the entity stored score.
  $field_value = $form_state
    ->getFormObject()
    ->getEntity()
    ->get('field_yoast_seo')
    ->getValue();
  $score = isset($field_value[0]['status']) ? $field_value[0]['status'] : 0;

  // Render the score markup.
  $output = $yoast_seo_manager
    ->getOverallScoreMarkup($score);
  $this
    ->formSet($form, 'field_yoast_seo.widget.0.yoast_seo.focus_keyword.#suffix', $output);
  return $form;
}