Commit 3c48ad8d authored by catch's avatar catch

Issue #2723553 by kim.pepper, jibran, mattc321: Trigger deprecated warning for ViewsData::get(NULL)

(cherry picked from commit 9ac5c2b9)
parent 80194631
......@@ -82,7 +82,7 @@ public function getHandler($item, $override = NULL) {
$table = $item['table'];
$field = $item['field'];
// Get the plugin manager for this type.
$data = $this->viewsData->get($table);
$data = $table ? $this->viewsData->get($table) : $this->viewsData->getAll();
if (isset($data[$field][$this->handlerType])) {
$definition = $data[$field][$this->handlerType];
......
......@@ -137,12 +137,14 @@ public function getAll() {
* removed in 9.0.0. Use getAll() instead.
*
* @see https://www.drupal.org/node/2723553
* @see https://www.drupal.org/node/3090442
*
* @return array
* An array of table data.
*/
public function get($key = NULL) {
if (!$key) {
@trigger_error('Calling get() without the $key argument is deprecated in drupal:8.2.0 and is required in drupal:9.0.0. See https://www.drupal.org/node/3090442', E_USER_DEPRECATED);
return $this->getAll();
}
if (!isset($this->storage[$key])) {
......@@ -297,7 +299,7 @@ protected function processEntityTypes(array &$data) {
public function fetchBaseTables() {
$tables = [];
foreach ($this->get() as $table => $info) {
foreach ($this->getAll() as $table => $info) {
if (!empty($info['table']['base'])) {
$tables[$table] = [
'title' => $info['table']['base']['title'],
......
......@@ -51,7 +51,7 @@ public function __construct(ViewsData $views_data) {
*/
public function fetchFields($base, $type, $grouping = FALSE, $sub_type = NULL) {
if (!$this->fields) {
$data = $this->data->get();
$data = $this->data->getAll();
// This constructs this ginormous multi dimensional array to
// collect the important data about fields. In the end,
// the structure looks a bit like this (using nid as an example)
......
......@@ -52,7 +52,7 @@ public function testHandlers() {
$this->addDefaultCommentField('node', 'article');
$object_types = array_keys(ViewExecutable::getHandlerTypes());
foreach ($this->container->get('views.views_data')->get() as $base_table => $info) {
foreach ($this->container->get('views.views_data')->getAll() as $base_table => $info) {
if (!isset($info['table']['base'])) {
continue;
}
......
......@@ -43,7 +43,7 @@ public function testFetchFields() {
->disableOriginalConstructor()
->getMock();
$views_data->expects($this->once())
->method('get')
->method('getAll')
->will($this->returnValue($this->viewsData()));
$data_helper = new ViewsDataHelper($views_data);
......
......@@ -642,6 +642,9 @@ public function testCacheCallsWithoutWarmCacheAndGetMultipleTables() {
* logic.
*
* @covers ::getAll
* @group legacy
*
* @expectedDeprecation Calling get() without the $key argument is deprecated in drupal:8.2.0 and is required in drupal:9.0.0. See https://www.drupal.org/node/3090442
*/
public function testGetAllEqualsToGetNull() {
$expected_views_data = $this->viewsDataWithProvider();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment