Skip to content
Snippets Groups Projects
Commit 6ee0b85c authored by Alex Skrypnyk's avatar Alex Skrypnyk Committed by Deployer Robot
Browse files

Issue #3454548 by alex.skrypnyk, abhishek_gupta1, ivrh,...

Issue #3454548 by alex.skrypnyk, abhishek_gupta1, ivrh, thisisalistairsaccount: Automated list from Banner bottom components throws error.
parent 86a65491
No related branches found
No related tags found
No related merge requests found
......@@ -63,8 +63,14 @@ function civictheme_preprocess_paragraph__civictheme_automated_list(array &$vari
unset($settings['paragraph']);
// Get view with already set display.
/** @var \Drupal\views\ViewExecutable $view */
$view = _civictheme_automated_list__get_view($settings);
try {
/** @var \Drupal\views\ViewExecutable $view */
$view = _civictheme_automated_list__get_view($settings);
}
catch (\Exception $e) {
\Drupal::logger('civictheme')->error($e->getMessage());
return;
}
$settings['view_id'] = $view->id();
$settings['view_display'] = $view->current_display;
......@@ -95,14 +101,16 @@ function civictheme_preprocess_paragraph__civictheme_automated_list(array &$vari
* @param array $settings
* View alteration settings passed by reference.
*
* @return \Drupal\views\ViewExecutable|null
* Loaded view object with set display or NULL.
* @return \Drupal\views\ViewExecutable
* Loaded view object with set display.
*
* @throws \Exception
* If view information is missing or view is not found.
* @see hook_civictheme_automated_list_view_info_alter()
*
* @SuppressWarnings(PHPMD.StaticAccess)
*/
function _civictheme_automated_list__get_view(array &$settings) {
function _civictheme_automated_list__get_view(array &$settings): ViewExecutable {
// Get information about a view and a display that will be used produce
// the results.
$info = [
......@@ -127,26 +135,18 @@ function _civictheme_automated_list__get_view(array &$settings) {
// Validate that resulting information has correct structure.
if (empty($info) || !is_array($info) || empty($info['view_name']) || empty($info['display_name'])) {
\Drupal::logger('civictheme')->error('Missing view_name or display_name information for Automated list view.');
return NULL;
throw new \Exception('Missing view_name or display_name information for Automated list view.');
}
// Get view instance.
$view = Views::getView($info['view_name']);
if ($view === NULL) {
\Drupal::logger('civictheme')->error(sprintf('Unable to use Automated list view "%s".', $info['view_name']));
// Do not render this element if the view does not exist.
return NULL;
throw new \Exception(sprintf('Unable to use Automated list view "%s".', $info['view_name']));
}
// Set display.
if (!$view->setDisplay($info['display_name'])) {
\Drupal::logger('civictheme')->error(sprintf('Unable to use Automated list view display "%s" for view "%s".', $info['display_name'], $info['view_name']));
// Do not render this element if the display does not exist.
return NULL;
throw new \Exception(sprintf('Unable to use Automated list view display "%s" for view "%s".', $info['display_name'], $info['view_name']));
}
return $view;
......
{"generatedAt":1719649688898,"builder":{"name":"webpack4"},"hasCustomBabel":false,"hasCustomWebpack":true,"hasStaticDirs":false,"hasStorybookEslint":false,"refCount":0,"packageManager":{"type":"npm","version":"8.19.4"},"storybookVersion":"6.5.16","language":"javascript","storybookPackages":{"@storybook/addons":{"version":"6.5.16"},"@storybook/html":{"version":"6.5.16"},"@storybook/preset-scss":{"version":"1.0.3"}},"framework":{"name":"html"},"addons":{"@storybook/addon-knobs":{"version":"6.4.0"},"@storybook/addon-essentials":{"options":{"controls":false,"docs":false,"actions":false},"version":"6.5.16"},"@storybook/addon-links":{"version":"6.5.16"},"@storybook/addon-a11y":{"version":"6.5.16"}}}
{"generatedAt":1719649921963,"builder":{"name":"webpack4"},"hasCustomBabel":false,"hasCustomWebpack":true,"hasStaticDirs":false,"hasStorybookEslint":false,"refCount":0,"packageManager":{"type":"npm","version":"8.19.4"},"storybookVersion":"6.5.16","language":"javascript","storybookPackages":{"@storybook/addons":{"version":"6.5.16"},"@storybook/html":{"version":"6.5.16"},"@storybook/preset-scss":{"version":"1.0.3"}},"framework":{"name":"html"},"addons":{"@storybook/addon-knobs":{"version":"6.4.0"},"@storybook/addon-essentials":{"options":{"controls":false,"docs":false,"actions":false},"version":"6.5.16"},"@storybook/addon-links":{"version":"6.5.16"},"@storybook/addon-a11y":{"version":"6.5.16"}}}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment