class EntityFormEnhancer

Enhances an entity form route with the appropriate controller.

Hierarchy

Expanded class hierarchy of EntityFormEnhancer

1 string reference to 'EntityFormEnhancer'
core.services.yml in drupal/core/core.services.yml
drupal/core/core.services.yml

File

drupal/core/lib/Drupal/Core/Entity/Enhancer/EntityFormEnhancer.php, line 17
Contains \Drupal\Core\Entity\Enhancer\EntityFormEnhancer.

Namespace

Drupal\Core\Entity\Enhancer
View source
class EntityFormEnhancer implements RouteEnhancerInterface {

  /**
   * Content negotiation library.
   *
   * @var \Drupal\CoreContentNegotiation
   */
  protected $negotiation;

  /**
   * Constructs a new \Drupal\Core\Entity\Enhancer\EntityFormEnhancer.
   *
   * @param \Drupal\Core\ContentNegotiation $negotiation
   *   The content negotiation library.
   */
  public function __construct(ContentNegotiation $negotiation) {
    $this->negotiation = $negotiation;
  }

  /**
   * {@inheritdoc}
   */
  public function enhance(array $defaults, Request $request) {
    if (empty($defaults['_controller']) && !empty($defaults['_entity_form']) && $this->negotiation
      ->getContentType($request) === 'html') {
      $defaults['_controller'] = '\\Drupal\\Core\\Entity\\HtmlEntityFormController::content';
    }
    return $defaults;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityFormEnhancer::$negotiation protected property Content negotiation library.
EntityFormEnhancer::enhance public function Update the defaults based on its own data and the request. Overrides RouteEnhancerInterface::enhance
EntityFormEnhancer::__construct public function Constructs a new \Drupal\Core\Entity\Enhancer\EntityFormEnhancer.