You are here

class FieldGroupConverter in Field Group 8

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

Parameter converter for upcasting fieldgroup config ids to fieldgroup object.

Hierarchy

Expanded class hierarchy of FieldGroupConverter

1 string reference to 'FieldGroupConverter'
field_group.services.yml in ./field_group.services.yml
field_group.services.yml
1 service uses FieldGroupConverter
field_group.param_converter in ./field_group.services.yml
Drupal\field_group\Routing\FieldGroupConverter

File

src/Routing/FieldGroupConverter.php, line 10

Namespace

Drupal\field_group\Routing
View source
class FieldGroupConverter implements ParamConverterInterface {

  /**
   * {@inheritdoc}
   */
  public function applies($definition, $name, \Symfony\Component\Routing\Route $route) {
    return isset($definition['type']) && $definition['type'] == 'field_group';
  }

  /**
   * {@inheritdoc}
   */
  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]);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FieldGroupConverter::applies public function Determines if the converter applies to a specific route and variable. Overrides ParamConverterInterface::applies
FieldGroupConverter::convert public function Converts path variables to their corresponding objects. Overrides ParamConverterInterface::convert