You are here

FieldGroupConverter.php in Field Group 8.3

Same filename and directory in other branches
  1. 8 src/Routing/FieldGroupConverter.php

File

src/Routing/FieldGroupConverter.php
View source
<?php

namespace Drupal\field_group\Routing;

use Symfony\Component\Routing\Route;
use Drupal\Core\ParamConverter\ParamConverterInterface;

/**
 * Parameter converter for upcasting fieldgroup config ids to fieldgroup object.
 */
class FieldGroupConverter implements ParamConverterInterface {

  /**
   * {@inheritdoc}
   */
  public function applies($definition, $name, 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]);
  }

}

Classes

Namesort descending Description
FieldGroupConverter Parameter converter for upcasting fieldgroup config ids to fieldgroup object.