Issue #2752463 by tstoeckler: EntityResolverManager::setParametersFromEntityInformation() sets parameter info for non-existing parameters
parent
182f8fd18b
commit
2f7924b3ab
|
@ -166,7 +166,10 @@ class EntityResolverManager {
|
|||
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();
|
||||
|
||||
// First try to figure out whether there is already a parameter upcasting
|
||||
|
|
|
@ -416,6 +416,27 @@ class EntityResolverManagerTest extends UnitTestCase {
|
|||
$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.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue