diff --git a/core/modules/views/src/Plugin/views/cache/Time.php b/core/modules/views/src/Plugin/views/cache/Time.php index 9d5d70b77b..b801b0a30b 100644 --- a/core/modules/views/src/Plugin/views/cache/Time.php +++ b/core/modules/views/src/Plugin/views/cache/Time.php @@ -47,13 +47,29 @@ class Time extends CachePluginBase { */ public function __construct(array $configuration, $plugin_id, $plugin_definition, DateFormatterInterface $date_formatter) { $this->dateFormatter = $date_formatter; - if (func_get_arg(3) && func_get_arg(3) instanceof Request) { - @trigger_error('The request object must not be passed to ' . __METHOD__ . '(). It is deprecated in drupal:9.1.0 and will be removed in drupal:10.0.0. See https://www.drupal.org/project/drupal/issues/3109109', E_USER_DEPRECATED); + if (func_num_args() == 5 && func_get_arg(4) instanceof Request) { + @trigger_error('The request object must not be passed to ' . __METHOD__ . '(). It is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. See https://www.drupal.org/node/3154016', E_USER_DEPRECATED); } parent::__construct($configuration, $plugin_id, $plugin_definition); } + /** + * Returns replacements for deprecated properties. + * + * @param string $name + * The property name. + * + * @return mixed + * The value. + */ + public function __get($name) { + if ($name === 'request') { + @trigger_error('The request property of ' . __CLASS__ . ' is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. See https://www.drupal.org/node/3154016', E_USER_DEPRECATED); + return $this->view->getRequest(); + } + } + /** * {@inheritdoc} */ diff --git a/core/modules/views/tests/src/Kernel/ViewsLegacyTest.php b/core/modules/views/tests/src/Kernel/ViewsLegacyTest.php new file mode 100644 index 0000000000..fae0441f49 --- /dev/null +++ b/core/modules/views/tests/src/Kernel/ViewsLegacyTest.php @@ -0,0 +1,42 @@ +getDefinition('time'), + \Drupal::service('date.formatter'), $request + ); + $view = $this->prophesize(ViewExecutable::class); + $view->getRequest()->willReturn($request); + $plugin->view = $view->reveal(); + $this->assertInstanceOf(Request::class, $plugin->request); + $this->assertSame($request, $plugin->request); + } + +}