You are here

public function FieldGroupConverter::convert in Field Group 8

Same name and namespace in other branches
  1. 8.3 src/Routing/FieldGroupConverter.php \Drupal\field_group\Routing\FieldGroupConverter::convert()

Converts path variables to their corresponding objects.

Parameters

mixed $value: The raw value.

mixed $definition: The parameter definition provided in the route options.

string $name: The name of the parameter.

array $defaults: The route defaults array.

Return value

mixed|null The converted parameter value.

Overrides ParamConverterInterface::convert

File

src/Routing/FieldGroupConverter.php, line 22

Class

FieldGroupConverter
Parameter converter for upcasting fieldgroup config ids to fieldgroup object.

Namespace

Drupal\field_group\Routing

Code

public function convert($value, $definition, $name, array $defaults) {
  $identifiers = explode('.', $value);
  if (count($identifiers) != 5) {
    return;
  }
  return field_group_load_field_group($identifiers[4], $identifiers[0], $identifiers[1], $identifiers[2], $identifiers[3]);
}