Skip to content
Snippets Groups Projects
Commit 2f7924b3 authored by catch's avatar catch
Browse files

Issue #2752463 by tstoeckler:...

Issue #2752463 by tstoeckler: EntityResolverManager::setParametersFromEntityInformation() sets parameter info for non-existing parameters
parent 182f8fd1
No related branches found
No related tags found
No related merge requests found
...@@ -166,7 +166,10 @@ protected function setParametersFromEntityInformation(Route $route) { ...@@ -166,7 +166,10 @@ protected function setParametersFromEntityInformation(Route $route) {
list($entity_type) = explode('.', $entity_form, 2); list($entity_type) = explode('.', $entity_form, 2);
} }
if (isset($entity_type) && isset($this->getEntityTypes()[$entity_type])) { // Do not add parameter information if the route does not declare a
// parameter in the first place. This is the case for add forms, for
// example.
if (isset($entity_type) && isset($this->getEntityTypes()[$entity_type]) && (strpos($route->getPath(), '{' . $entity_type . '}') !== FALSE)) {
$parameter_definitions = $route->getOption('parameters') ?: array(); $parameter_definitions = $route->getOption('parameters') ?: array();
// First try to figure out whether there is already a parameter upcasting // First try to figure out whether there is already a parameter upcasting
......
...@@ -416,6 +416,27 @@ public function testSetRouteOptionsWithEntityFormRouteAndArgument() { ...@@ -416,6 +416,27 @@ public function testSetRouteOptionsWithEntityFormRouteAndArgument() {
$this->assertEquals($expect, $parameters); $this->assertEquals($expect, $parameters);
} }
/**
* Tests setRouteOptions() with an _entity_form route for an add form.
*
* @covers ::setRouteOptions
* @covers ::getControllerClass
* @covers ::getEntityTypes
* @covers ::setParametersFromReflection
* @covers ::setParametersFromEntityInformation
*/
public function testSetRouteOptionsWithEntityAddFormRoute() {
$this->setupEntityTypes();
$route = new Route('/example/add', array(
'_entity_form' => 'entity_test.add',
));
$defaults = $route->getDefaults();
$this->entityResolverManager->setRouteOptions($route);
$this->assertEquals($defaults, $route->getDefaults());
$this->assertFalse($route->hasOption('parameters'));
}
/** /**
* Creates the entity manager mock returning entity type objects. * Creates the entity manager mock returning entity type objects.
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment