Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Problem/Motivation
Original code:
/**
* Loads a view from configuration and returns its executable object.
*
* @param string $id
* The view ID to load.
*
* @return \Drupal\views\ViewExecutable
* A view executable instance, from the loaded entity.
*/
public static function getView($id) {
$view = \Drupal::entityTypeManager()->getStorage('view')->load($id);
if ($view) {
return static::executableFactory()->get($view);
}
}
Proposed resolution
/**
* Loads a view from configuration and returns its executable object.
*
* @param string $id
* The view ID to load.
*
* @return \Drupal\views\ViewExecutable|null
* A view executable instance, from the loaded entity.
*/
public static function getView($id) {
$view = \Drupal::entityTypeManager()->getStorage('view')->load($id);
if ($view) {
return static::executableFactory()->get($view);
}
return NULL;
}
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#8 | 3150474-8.patch | 2.05 KB | jungle |
#8 | interdiff-4-8.txt | 1.89 KB | jungle |
#8 | 3150474-8-test-only.patch | 1.29 KB | jungle |
Comments
Comment #2
munish.kumar CreditAttribution: munish.kumar as a volunteer and at Srijan | A Material+ Company for Drupal India Association commentedComment #3
jungleThanks, @munish.kumar for picking it up, just a reminder, the comment "A view executable instance, from the loaded entity." should be updated as well.
Comment #4
munish.kumar CreditAttribution: munish.kumar as a volunteer and at Srijan | A Material+ Company for Drupal India Association commentedThanks @jungle for pointing these changes as well. As discussed I have updated the comment in the patch. Please review.
Comment #6
jungleA random failure, re-queued.
Comment #7
siddhant.bhosale CreditAttribution: siddhant.bhosale as a volunteer and at QED42 commentedComment #8
jungleAdded a test "Tests the getView() method against a non-existent view.", but the test-only patch will pass, as by default if the return statement is missing, it returns NULL.
Comment #9
siddhant.bhosale CreditAttribution: siddhant.bhosale as a volunteer and at QED42 commentedHi, I have tested the patch and looks good to be merged.
Comment #10
alexpottCommitted and pushed 19d2c39d0d to 9.1.x and e8cdb1d61f to 9.0.x and fd046df3d9 to 8.9.x. Thanks!