You are here

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

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/schema_metatag.base.test
Confirm that tags can be saved and that the output of each tag is correct.

File

tests/schema_metatag.base.test, line 32

Class

SchemaMetatagTagsTestBase
Base class for testing a module's custom tags.

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;
}