Skip to content

Commit

Permalink
Fixes PHPstan errors (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
thejimbirch committed Mar 2, 2024
1 parent b3e3cf8 commit 43655ff
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions saplings_custom.module
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* Contains saplings_custom functionality.
*/

use Drupal\node\NodeInterface;

/**
* Implements hook_preprocess_html() for html templates.
*
Expand All @@ -17,19 +19,19 @@ function saplings_custom_preprocess_html(array &$variables) {
// Get the value of the field.
if ($node->hasField('sa_robots')) {
$robots_field = $node->get('sa_robots')->getString();
}
// Only render if the field has value.
if ($robots_field) {
$variables['page']['#attached']['html_head'][] = [
[
'#tag' => 'meta',
'#attributes' => [
'name' => 'robots',
'content' => $robots_field,
// Only render if the field has value.
if ($robots_field) {
$variables['page']['#attached']['html_head'][] = [
[
'#tag' => 'meta',
'#attributes' => [
'name' => 'robots',
'content' => $robots_field,
],
],
],
'robots',
];
'robots',
];
}
}
}
}

0 comments on commit 43655ff

Please sign in to comment.