class FieldUI

Same name in other branches
  1. 9 core/modules/field_ui/src/FieldUI.php \Drupal\field_ui\FieldUI
  2. 8.9.x core/modules/field_ui/src/FieldUI.php \Drupal\field_ui\FieldUI
  3. 11.x core/modules/field_ui/src/FieldUI.php \Drupal\field_ui\FieldUI

Static service container wrapper for Field UI.

Hierarchy

Expanded class hierarchy of FieldUI

12 files declare their use of FieldUI
EntityDisplayFormBase.php in core/modules/field_ui/src/Form/EntityDisplayFormBase.php
EntityDisplayModeFormBase.php in core/modules/field_ui/src/Form/EntityDisplayModeFormBase.php
EntityFormDisplayEditForm.php in core/modules/field_ui/src/Form/EntityFormDisplayEditForm.php
EntityViewDisplayEditForm.php in core/modules/field_ui/src/Form/EntityViewDisplayEditForm.php
FieldConfigDeleteForm.php in core/modules/field_ui/src/Form/FieldConfigDeleteForm.php

... See full list

File

core/modules/field_ui/src/FieldUI.php, line 12

Namespace

Drupal\field_ui
View source
class FieldUI {
    
    /**
     * Returns the route info for the field overview of a given entity bundle.
     *
     * @param string $entity_type_id
     *   An entity type.
     * @param string $bundle
     *   The entity bundle.
     *
     * @return \Drupal\Core\Url
     *   A URL object.
     */
    public static function getOverviewRouteInfo($entity_type_id, $bundle) {
        $entity_type = \Drupal::entityTypeManager()->getDefinition($entity_type_id);
        if ($entity_type->get('field_ui_base_route')) {
            return new Url("entity.{$entity_type_id}.field_ui_fields", static::getRouteBundleParameter($entity_type, $bundle));
        }
    }
    
    /**
     * Returns the next redirect path in a multi-page sequence.
     *
     * @param array $destinations
     *   An array of destinations to redirect to.
     *
     * @return \Drupal\Core\Url|null
     *   The next destination to redirect to.
     */
    public static function getNextDestination(array $destinations) {
        // If there are no valid destinations left, return here.
        if (empty($destinations)) {
            return NULL;
        }
        $next_destination = array_shift($destinations);
        if (is_array($next_destination)) {
            $next_destination['options']['query']['destinations'] = $destinations;
            $next_destination += [
                'route_parameters' => [],
            ];
            $next_destination = Url::fromRoute($next_destination['route_name'], $next_destination['route_parameters'], $next_destination['options']);
        }
        else {
            $options = UrlHelper::parse($next_destination);
            if ($destinations) {
                $options['query']['destinations'] = $destinations;
            }
            // Redirect to any given path within the same domain.
            // @todo Revisit this in https://www.drupal.org/node/2418219.
            $next_destination = Url::fromUserInput('/' . $options['path'], $options);
        }
        return $next_destination;
    }
    
    /**
     * Gets the route parameter that should be used for Field UI routes.
     *
     * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
     *   The actual entity type, not the bundle (e.g. the content entity type).
     * @param string $bundle
     *   The bundle name.
     *
     * @return array
     *   An array that can be used a route parameter.
     */
    public static function getRouteBundleParameter(EntityTypeInterface $entity_type, $bundle) {
        $bundle_parameter_key = $entity_type->getBundleEntityType() ?: 'bundle';
        return [
            $bundle_parameter_key => $bundle,
        ];
    }

}

Members

Title Sort descending Modifiers Object type Summary
FieldUI::getNextDestination public static function Returns the next redirect path in a multi-page sequence.
FieldUI::getOverviewRouteInfo public static function Returns the route info for the field overview of a given entity bundle.
FieldUI::getRouteBundleParameter public static function Gets the route parameter that should be used for Field UI routes.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.