You are here

public function SchemaMetatagTagsTestBase::getKey in Schema.org Metatag 8.2

Same name and namespace in other branches
  1. 8 tests/src/Functional/SchemaMetatagTagsTestBase.php \Drupal\Tests\schema_metatag\Functional\SchemaMetatagTagsTestBase::getKey()

Convert the tag_name into the camelCase key used in the JSON array.

Parameters

string $tag_name: The name of the tag.

Return value

string The key used in the JSON array for this tag.

1 call to SchemaMetatagTagsTestBase::getKey()
SchemaMetatagTagsTestBase::testTagsInputOutput in tests/src/Functional/SchemaMetatagTagsTestBase.php
Confirm that tags can be saved and that the output of each tag is correct.

File

tests/src/Functional/SchemaMetatagTagsTestBase.php, line 140

Class

SchemaMetatagTagsTestBase
Base class to test all of the meta tags that are in a specific module.

Namespace

Drupal\Tests\schema_metatag\Functional

Code

public function getKey($tag_name) {
  $key = str_replace($this->moduleName . '_', '', $tag_name);
  $parts = explode('_', $key);
  foreach ($parts as $i => $part) {
    $parts[$i] = $i > 0 ? ucfirst($part) : $part;
  }
  $key = implode($parts);
  if (in_array($key, [
    'type',
    'id',
  ])) {
    $key = '@' . $key;
  }
  return $key;
}