summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2014-09-08 13:19:52 (GMT)
committerNathaniel Catchpole2014-09-08 13:20:21 (GMT)
commit12feabd38cd5254031a22f35f94dd43eecd6d655 (patch)
tree20a17bec08f2cd870a866e6ecc497613424d0a68
parent29c4def340788bdf33e52c90059bfc31112a36cb (diff)
Issue #2330929 by znerol: Remove the request from parameter converters.
-rw-r--r--core/lib/Drupal/Core/Access/AccessManager.php2
-rw-r--r--core/lib/Drupal/Core/ParamConverter/AdminPathConfigEntityConverter.php5
-rw-r--r--core/lib/Drupal/Core/ParamConverter/EntityConverter.php3
-rw-r--r--core/lib/Drupal/Core/ParamConverter/MenuLinkPluginConverter.php3
-rw-r--r--core/lib/Drupal/Core/ParamConverter/ParamConverterInterface.php5
-rw-r--r--core/lib/Drupal/Core/ParamConverter/ParamConverterManager.php6
-rw-r--r--core/lib/Drupal/Core/ParamConverter/ParamConverterManagerInterface.php5
-rw-r--r--core/lib/Drupal/Core/Routing/Enhancer/ParamConversionEnhancer.php2
-rw-r--r--core/modules/language/src/LanguageConverter.php3
-rw-r--r--core/modules/node/src/ParamConverter/NodePreviewConverter.php3
-rw-r--r--core/modules/views_ui/src/ParamConverter/ViewUIConverter.php5
-rw-r--r--core/tests/Drupal/Tests/Core/Enhancer/ParamConversionEnhancerTest.php4
-rw-r--r--core/tests/Drupal/Tests/Core/ParamConverter/EntityConverterTest.php7
-rw-r--r--core/tests/Drupal/Tests/Core/ParamConverter/ParamConverterManagerTest.php11
14 files changed, 24 insertions, 40 deletions
diff --git a/core/lib/Drupal/Core/Access/AccessManager.php b/core/lib/Drupal/Core/Access/AccessManager.php
index 8a8af77..4f30a2d 100644
--- a/core/lib/Drupal/Core/Access/AccessManager.php
+++ b/core/lib/Drupal/Core/Access/AccessManager.php
@@ -205,7 +205,7 @@ class AccessManager implements ContainerAwareInterface, AccessManagerInterface {
$parameters += $route->getDefaults();
$route_request->attributes->set('_raw_variables', new ParameterBag($parameters));
$parameters[RouteObjectInterface::ROUTE_OBJECT] = $route;
- $route_request->attributes->add($this->paramConverterManager->convert($parameters, $route_request));
+ $route_request->attributes->add($this->paramConverterManager->convert($parameters));
}
return $this->check($route, $route_request, $account);
}
diff --git a/core/lib/Drupal/Core/ParamConverter/AdminPathConfigEntityConverter.php b/core/lib/Drupal/Core/ParamConverter/AdminPathConfigEntityConverter.php
index 45a6c61..89c5914 100644
--- a/core/lib/Drupal/Core/ParamConverter/AdminPathConfigEntityConverter.php
+++ b/core/lib/Drupal/Core/ParamConverter/AdminPathConfigEntityConverter.php
@@ -8,7 +8,6 @@
namespace Drupal\Core\ParamConverter;
use Drupal\Core\Routing\AdminContext;
-use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Route;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityManagerInterface;
@@ -63,7 +62,7 @@ class AdminPathConfigEntityConverter extends EntityConverter {
/**
* {@inheritdoc}
*/
- public function convert($value, $definition, $name, array $defaults, Request $request) {
+ public function convert($value, $definition, $name, array $defaults) {
$entity_type_id = $this->getEntityTypeFromDefaults($definition, $name, $defaults);
// If the entity type is dynamic, confirm it to be a config entity. Static
@@ -71,7 +70,7 @@ class AdminPathConfigEntityConverter extends EntityConverter {
if (strpos($definition['type'], 'entity:{') === 0) {
$entity_type = $this->entityManager->getDefinition($entity_type_id);
if (!$entity_type->isSubclassOf('\Drupal\Core\Config\Entity\ConfigEntityInterface')) {
- return parent::convert($value, $definition, $name, $defaults, $request);
+ return parent::convert($value, $definition, $name, $defaults);
}
}
diff --git a/core/lib/Drupal/Core/ParamConverter/EntityConverter.php b/core/lib/Drupal/Core/ParamConverter/EntityConverter.php
index 95ccd0e..683fdff 100644
--- a/core/lib/Drupal/Core/ParamConverter/EntityConverter.php
+++ b/core/lib/Drupal/Core/ParamConverter/EntityConverter.php
@@ -8,7 +8,6 @@
namespace Drupal\Core\ParamConverter;
use Drupal\Core\Entity\EntityManagerInterface;
-use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Route;
/**
@@ -62,7 +61,7 @@ class EntityConverter implements ParamConverterInterface {
/**
* {@inheritdoc}
*/
- public function convert($value, $definition, $name, array $defaults, Request $request) {
+ public function convert($value, $definition, $name, array $defaults) {
$entity_type_id = $this->getEntityTypeFromDefaults($definition, $name, $defaults);
if ($storage = $this->entityManager->getStorage($entity_type_id)) {
return $storage->load($value);
diff --git a/core/lib/Drupal/Core/ParamConverter/MenuLinkPluginConverter.php b/core/lib/Drupal/Core/ParamConverter/MenuLinkPluginConverter.php
index b3c2dcf..848b05a 100644
--- a/core/lib/Drupal/Core/ParamConverter/MenuLinkPluginConverter.php
+++ b/core/lib/Drupal/Core/ParamConverter/MenuLinkPluginConverter.php
@@ -9,7 +9,6 @@ namespace Drupal\Core\ParamConverter;
use Drupal\Core\Menu\MenuLinkManagerInterface;
use Drupal\Component\Plugin\Exception\PluginException;
-use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Route;
/**
@@ -37,7 +36,7 @@ class MenuLinkPluginConverter implements ParamConverterInterface {
/**
* {@inheritdoc}
*/
- public function convert($value, $definition, $name, array $defaults, Request $request) {
+ public function convert($value, $definition, $name, array $defaults) {
if ($value) {
try {
return $this->menuLinkManager->createInstance($value);
diff --git a/core/lib/Drupal/Core/ParamConverter/ParamConverterInterface.php b/core/lib/Drupal/Core/ParamConverter/ParamConverterInterface.php
index 957dfd9..141e32a 100644
--- a/core/lib/Drupal/Core/ParamConverter/ParamConverterInterface.php
+++ b/core/lib/Drupal/Core/ParamConverter/ParamConverterInterface.php
@@ -7,7 +7,6 @@
namespace Drupal\Core\ParamConverter;
-use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Route;
/**
@@ -26,13 +25,11 @@ interface ParamConverterInterface {
* The name of the parameter.
* @param array $defaults
* The route defaults array.
- * @param \Symfony\Component\HttpFoundation\Request $request
- * The request object.
*
* @return mixed|null
* The converted parameter value.
*/
- public function convert($value, $definition, $name, array $defaults, Request $request);
+ public function convert($value, $definition, $name, array $defaults);
/**
* Determines if the converter applies to a specific route and variable.
diff --git a/core/lib/Drupal/Core/ParamConverter/ParamConverterManager.php b/core/lib/Drupal/Core/ParamConverter/ParamConverterManager.php
index cfc8963..8719cd9 100644
--- a/core/lib/Drupal/Core/ParamConverter/ParamConverterManager.php
+++ b/core/lib/Drupal/Core/ParamConverter/ParamConverterManager.php
@@ -11,7 +11,6 @@ use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
use Symfony\Component\Routing\RouteCollection;
-use Symfony\Component\HttpFoundation\Request;
/**
* Manages converter services for converting request parameters to full objects.
@@ -81,7 +80,7 @@ class ParamConverterManager implements ParamConverterManagerInterface {
/**
* {@inheritdoc}
*/
- public function convert(array $defaults, Request $request) {
+ public function convert(array $defaults) {
/** @var $route \Symfony\Component\Routing\Route */
$route = $defaults[RouteObjectInterface::ROUTE_OBJECT];
@@ -104,7 +103,7 @@ class ParamConverterManager implements ParamConverterManagerInterface {
// If a converter returns NULL it means that the parameter could not be
// converted.
- $defaults[$name] = $this->getConverter($definition['converter'])->convert($defaults[$name], $definition, $name, $defaults, $request);
+ $defaults[$name] = $this->getConverter($definition['converter'])->convert($defaults[$name], $definition, $name, $defaults);
if (!isset($defaults[$name])) {
throw new ParamNotConvertedException(sprintf('The "%s" parameter was not converted for the path "%s" (route name: "%s")', $name, $route->getPath(), $defaults[RouteObjectInterface::ROUTE_NAME]));
}
@@ -114,4 +113,3 @@ class ParamConverterManager implements ParamConverterManagerInterface {
}
}
-
diff --git a/core/lib/Drupal/Core/ParamConverter/ParamConverterManagerInterface.php b/core/lib/Drupal/Core/ParamConverter/ParamConverterManagerInterface.php
index a1761da..77f69c5 100644
--- a/core/lib/Drupal/Core/ParamConverter/ParamConverterManagerInterface.php
+++ b/core/lib/Drupal/Core/ParamConverter/ParamConverterManagerInterface.php
@@ -7,7 +7,6 @@
namespace Drupal\Core\ParamConverter;
-use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\RouteCollection;
/**
@@ -54,8 +53,6 @@ interface ParamConverterManagerInterface {
*
* @param array $defaults
* The route defaults array.
- * @param \Symfony\Component\HttpFoundation\Request $request
- * The current request.
*
* @throws \Drupal\Core\ParamConverter\ParamNotConvertedException
* If one of the assigned converters returned NULL because the given
@@ -64,6 +61,6 @@ interface ParamConverterManagerInterface {
* @return array
* The modified defaults.
*/
- public function convert(array $defaults, Request $request);
+ public function convert(array $defaults);
}
diff --git a/core/lib/Drupal/Core/Routing/Enhancer/ParamConversionEnhancer.php b/core/lib/Drupal/Core/Routing/Enhancer/ParamConversionEnhancer.php
index 614ac96..6785b95 100644
--- a/core/lib/Drupal/Core/Routing/Enhancer/ParamConversionEnhancer.php
+++ b/core/lib/Drupal/Core/Routing/Enhancer/ParamConversionEnhancer.php
@@ -45,7 +45,7 @@ class ParamConversionEnhancer implements RouteEnhancerInterface, EventSubscriber
*/
public function enhance(array $defaults, Request $request) {
$defaults['_raw_variables'] = $this->copyRawVariables($defaults);
- return $this->paramConverterManager->convert($defaults, $request);
+ return $this->paramConverterManager->convert($defaults);
}
/**
diff --git a/core/modules/language/src/LanguageConverter.php b/core/modules/language/src/LanguageConverter.php
index 0bcc265..fdfb58a2 100644
--- a/core/modules/language/src/LanguageConverter.php
+++ b/core/modules/language/src/LanguageConverter.php
@@ -9,7 +9,6 @@ namespace Drupal\language;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\ParamConverter\ParamConverterInterface;
-use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Route;
/**
@@ -37,7 +36,7 @@ class LanguageConverter implements ParamConverterInterface {
/**
* {@inheritdoc}
*/
- public function convert($value, $definition, $name, array $defaults, Request $request) {
+ public function convert($value, $definition, $name, array $defaults) {
if (!empty($value)) {
return $this->languageManager->getLanguage($value);
}
diff --git a/core/modules/node/src/ParamConverter/NodePreviewConverter.php b/core/modules/node/src/ParamConverter/NodePreviewConverter.php
index adf22ee..edba0ff 100644
--- a/core/modules/node/src/ParamConverter/NodePreviewConverter.php
+++ b/core/modules/node/src/ParamConverter/NodePreviewConverter.php
@@ -8,7 +8,6 @@
namespace Drupal\node\ParamConverter;
use Drupal\Core\Entity\EntityManagerInterface;
-use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Route;
use Drupal\Core\ParamConverter\ParamConverterInterface;
use Drupal\user\TempStoreFactory;
@@ -38,7 +37,7 @@ class NodePreviewConverter implements ParamConverterInterface {
/**
* {@inheritdoc}
*/
- public function convert($value, $definition, $name, array $defaults, Request $request) {
+ public function convert($value, $definition, $name, array $defaults) {
$store = $this->tempStoreFactory->get('node_preview');
if ($form_state = $store->get($value)) {
return $form_state->getFormObject()->getEntity();
diff --git a/core/modules/views_ui/src/ParamConverter/ViewUIConverter.php b/core/modules/views_ui/src/ParamConverter/ViewUIConverter.php
index a21cd0e..1a6fa99 100644
--- a/core/modules/views_ui/src/ParamConverter/ViewUIConverter.php
+++ b/core/modules/views_ui/src/ParamConverter/ViewUIConverter.php
@@ -9,7 +9,6 @@ namespace Drupal\views_ui\ParamConverter;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\ParamConverter\EntityConverter;
-use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Route;
use Drupal\Core\ParamConverter\ParamConverterInterface;
use Drupal\user\TempStoreFactory;
@@ -55,8 +54,8 @@ class ViewUIConverter extends EntityConverter implements ParamConverterInterface
/**
* {@inheritdoc}
*/
- public function convert($value, $definition, $name, array $defaults, Request $request) {
- if (!$entity = parent::convert($value, $definition, $name, $defaults, $request)) {
+ public function convert($value, $definition, $name, array $defaults) {
+ if (!$entity = parent::convert($value, $definition, $name, $defaults)) {
return;
}
diff --git a/core/tests/Drupal/Tests/Core/Enhancer/ParamConversionEnhancerTest.php b/core/tests/Drupal/Tests/Core/Enhancer/ParamConversionEnhancerTest.php
index bfc089e..e077f9c 100644
--- a/core/tests/Drupal/Tests/Core/Enhancer/ParamConversionEnhancerTest.php
+++ b/core/tests/Drupal/Tests/Core/Enhancer/ParamConversionEnhancerTest.php
@@ -61,7 +61,7 @@ class ParamConversionEnhancerTest extends UnitTestCase {
$this->paramConverterManager->expects($this->any())
->method('convert')
- ->with($this->isType('array'), $this->isInstanceOf('Symfony\Component\HttpFoundation\Request'))
+ ->with($this->isType('array'))
->will($this->returnValue($expected));
$result = $this->paramConversionEnhancer->enhance($defaults, new Request());
@@ -82,7 +82,7 @@ class ParamConversionEnhancerTest extends UnitTestCase {
$defaults['bar'] = &$defaults['id'];
$this->paramConverterManager->expects($this->any())
->method('convert')
- ->with($this->isType('array'), $this->isInstanceOf('Symfony\Component\HttpFoundation\Request'))
+ ->with($this->isType('array'))
->will($this->returnCallback(function ($defaults) {
// Convert the mirrored default to another value.
$defaults['bar'] = '2';
diff --git a/core/tests/Drupal/Tests/Core/ParamConverter/EntityConverterTest.php b/core/tests/Drupal/Tests/Core/ParamConverter/EntityConverterTest.php
index baeb0c4..36919a6 100644
--- a/core/tests/Drupal/Tests/Core/ParamConverter/EntityConverterTest.php
+++ b/core/tests/Drupal/Tests/Core/ParamConverter/EntityConverterTest.php
@@ -9,7 +9,6 @@ namespace Drupal\Tests\Core\ParamConverter;
use Drupal\Core\ParamConverter\EntityConverter;
use Drupal\Tests\UnitTestCase;
-use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Route;
/**
@@ -95,7 +94,7 @@ class EntityConverterTest extends UnitTestCase {
['invalid_id', NULL],
]);
- $this->assertEquals($expected_result, $this->entityConverter->convert($value, $definition, 'foo', $defaults, new Request()));
+ $this->assertEquals($expected_result, $this->entityConverter->convert($value, $definition, 'foo', $defaults));
}
/**
@@ -124,7 +123,7 @@ class EntityConverterTest extends UnitTestCase {
->with('invalid_id')
->willThrowException(new \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException('invalid_id'));
- $this->entityConverter->convert('id', ['type' => 'entity:invalid_id'], 'foo', ['foo' => 'id'], new Request());
+ $this->entityConverter->convert('id', ['type' => 'entity:invalid_id'], 'foo', ['foo' => 'id']);
}
/**
@@ -134,7 +133,7 @@ class EntityConverterTest extends UnitTestCase {
* @expectedExceptionMessage The "foo" parameter was not converted because the "invalid_id" parameter is missing
*/
public function testConvertWithInvalidDynamicEntityType() {
- $this->entityConverter->convert('id', ['type' => 'entity:{invalid_id}'], 'foo', ['foo' => 'id'], new Request());
+ $this->entityConverter->convert('id', ['type' => 'entity:{invalid_id}'], 'foo', ['foo' => 'id']);
}
}
diff --git a/core/tests/Drupal/Tests/Core/ParamConverter/ParamConverterManagerTest.php b/core/tests/Drupal/Tests/Core/ParamConverter/ParamConverterManagerTest.php
index 5a89e89..3519ec7 100644
--- a/core/tests/Drupal/Tests/Core/ParamConverter/ParamConverterManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/ParamConverter/ParamConverterManagerTest.php
@@ -10,7 +10,6 @@ namespace Drupal\Tests\Core\ParamConverter;
use Drupal\Core\ParamConverter\ParamConverterManager;
use Drupal\Tests\UnitTestCase;
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
-use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
@@ -199,11 +198,11 @@ class ParamConverterManagerTest extends UnitTestCase {
$converter = $this->getMock('Drupal\Core\ParamConverter\ParamConverterInterface');
$converter->expects($this->any())
->method('convert')
- ->with(1, $this->isType('array'), 'id', $this->isType('array'), $this->isInstanceOf('Symfony\Component\HttpFoundation\Request'))
+ ->with(1, $this->isType('array'), 'id', $this->isType('array'))
->will($this->returnValue('something_better!'));
$this->manager->addConverter($converter, 'test_convert');
- $result = $this->manager->convert($defaults, new Request());
+ $result = $this->manager->convert($defaults);
$this->assertEquals($expected, $result);
}
@@ -220,7 +219,7 @@ class ParamConverterManagerTest extends UnitTestCase {
$expected = $defaults;
- $result = $this->manager->convert($defaults, new Request());
+ $result = $this->manager->convert($defaults);
$this->assertEquals($expected, $result);
}
@@ -248,11 +247,11 @@ class ParamConverterManagerTest extends UnitTestCase {
$converter = $this->getMock('Drupal\Core\ParamConverter\ParamConverterInterface');
$converter->expects($this->any())
->method('convert')
- ->with(1, $this->isType('array'), 'id', $this->isType('array'), $this->isInstanceOf('Symfony\Component\HttpFoundation\Request'))
+ ->with(1, $this->isType('array'), 'id', $this->isType('array'))
->will($this->returnValue(NULL));
$this->manager->addConverter($converter, 'test_convert');
- $this->manager->convert($defaults, new Request());
+ $this->manager->convert($defaults);
}
}