Commit e1cbad3f authored by catch's avatar catch
Browse files

Revert "Issue #2934995 by benjifisher, larowlan, paulocs, AaronMcHale,...

Revert "Issue #2934995 by benjifisher, larowlan, paulocs, AaronMcHale, vikashsoni, danflanagan8, Berdir, SKAUGHT, alexpott: Add a "Manage permissions" tab for each bundle that has associated permissions"

This reverts commit 91fdb8aa.
parent dbe62991
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -1074,11 +1074,6 @@ services:
    class: Drupal\Core\Entity\Enhancer\EntityRouteEnhancer
    tags:
      - { name: route_enhancer, priority: 20 }
  route_enhancer.entity_bundle:
    class: Drupal\Core\Entity\Enhancer\EntityBundleRouteEnhancer
    arguments: ['@entity_type.manager']
    tags:
      - { name: route_enhancer }
  route_enhancer.entity_revision:
    class: Drupal\Core\Routing\Enhancer\EntityRevisionRouteEnhancer
    tags:
+0 −57
Original line number Diff line number Diff line
<?php

namespace Drupal\Core\Entity\Enhancer;

use Drupal\Core\Routing\EnhancerInterface;
use Drupal\Core\Routing\RouteObjectInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Route;

/**
 * Sets the bundle parameter for routes with the _field_ui option.
 */
class EntityBundleRouteEnhancer implements EnhancerInterface {

  /**
   * The entity type manager service.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * Constructs a EntityBundleRouteEnhancer object.
   *
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   The entity type manager service.
   */
  public function __construct(EntityTypeManagerInterface $entity_type_manager) {
    $this->entityTypeManager = $entity_type_manager;
  }

  /**
   * {@inheritdoc}
   */
  public function enhance(array $defaults, Request $request) {
    if (!$this->applies($defaults[RouteObjectInterface::ROUTE_OBJECT])) {
      return $defaults;
    }
    if (($bundle = $this->entityTypeManager->getDefinition($defaults['entity_type_id'])->getBundleEntityType()) && isset($defaults[$bundle])) {
      // Field UI forms only need the actual name of the bundle they're dealing
      // with, not an upcasted entity object, so provide a simple way for them
      // to get it.
      $defaults['bundle'] = $defaults['_raw_variables']->get($bundle);
    }

    return $defaults;
  }

  /**
   * {@inheritdoc}
   */
  protected function applies(Route $route) {
    return ($route->hasOption('_field_ui'));
  }

}
+1 −3
Original line number Diff line number Diff line
@@ -5,9 +5,7 @@ services:
    tags:
     - { name: event_subscriber }
  field_ui.route_enhancer:
    alias: route_enhancer.entity_bundle
    deprecated: The "%alias_id%" service is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use the "route_enhancer.entity_bundle" service instead. See https://www.drupal.org/node/3245017
    class: Drupal\Core\Entity\Enhancer\EntityBundleRouteEnhancer
    class: Drupal\field_ui\Routing\FieldUiRouteEnhancer
    arguments: ['@entity_type.manager']
    tags:
      - { name: route_enhancer }
+49 −9
Original line number Diff line number Diff line
@@ -2,16 +2,56 @@

namespace Drupal\field_ui\Routing;

@trigger_error('The ' . __NAMESPACE__ . '\EntityBundleRouteEnhancer is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Instead, use \Drupal\Core\Entity\Enhancer\EntityBundleRouteEnhancer. See https://www.drupal.org/node/3245017', E_USER_DEPRECATED);

use Drupal\Core\Entity\Enhancer\EntityBundleRouteEnhancer;
use Drupal\Core\Routing\EnhancerInterface;
use Drupal\Core\Routing\RouteObjectInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Route;

/**
 * Enhances Field UI routes by adding proper information about the bundle name.
 */
class FieldUiRouteEnhancer implements EnhancerInterface {

  /**
   * The entity type manager service.
   *
 * @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0.
 * Use \Drupal\Core\Entity\Enhancer\EntityBundleRouteEnhancer.
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * Constructs a FieldUiRouteEnhancer object.
   *
 * @see https://www.drupal.org/node/3245017
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   The entity type manager service.
   */
class FieldUiRouteEnhancer extends EntityBundleRouteEnhancer {}
  public function __construct(EntityTypeManagerInterface $entity_type_manager) {
    $this->entityTypeManager = $entity_type_manager;
  }

  /**
   * {@inheritdoc}
   */
  public function enhance(array $defaults, Request $request) {
    if (!$this->applies($defaults[RouteObjectInterface::ROUTE_OBJECT])) {
      return $defaults;
    }
    if (($bundle = $this->entityTypeManager->getDefinition($defaults['entity_type_id'])->getBundleEntityType()) && isset($defaults[$bundle])) {
      // Field UI forms only need the actual name of the bundle they're dealing
      // with, not an upcasted entity object, so provide a simple way for them
      // to get it.
      $defaults['bundle'] = $defaults['_raw_variables']->get($bundle);
    }

    return $defaults;
  }

  /**
   * {@inheritdoc}
   */
  protected function applies(Route $route) {
    return ($route->hasOption('_field_ui'));
  }

}
+0 −32
Original line number Diff line number Diff line
<?php

namespace Drupal\Tests\field_ui\Kernel;

use Drupal\KernelTests\KernelTestBase;

/**
 * Tests that the service "field_ui.route_enhancer" has been deprecated.
 *
 * @group field_ui
 * @group legacy
 */
class FieldUiRouteEnhancerTest extends KernelTestBase {

  /**
   * Modules to install.
   *
   * @var string[]
   */
  protected static $modules = ['field_ui'];

  /**
   * Tests deprecation of the "field_ui.route_enhancer" service.
   */
  public function testFieldUiRouteEnhancerDeprecation() {
    $this->expectDeprecation('The "field_ui.route_enhancer" service is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use the "route_enhancer.entity_bundle" service instead. See https://www.drupal.org/node/3245017');
    $legacy_service = \Drupal::service('field_ui.route_enhancer');
    $new_service = \Drupal::service('route_enhancer.entity_bundle');
    $this->assertSame($new_service, $legacy_service);
  }

}
Loading