Skip to content
Snippets Groups Projects
Commit c065d673 authored by Alec Smrekar's avatar Alec Smrekar
Browse files

Avoid exception on empty link href/title

parent 1e5a9a8e
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,7 @@ use Drupal\Core\Cache\RefinableCacheableDependencyInterface;
use Drupal\Core\Config\Config;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Menu\MenuLinkTreeElement;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use GuzzleHttp\Client;
/**
......@@ -18,6 +19,8 @@ use GuzzleHttp\Client;
*/
class RemoteMenuParser {
use StringTranslationTrait;
/**
* The HTTP client.
*
......@@ -97,7 +100,9 @@ class RemoteMenuParser {
// Convert a flat JSON into a tree array.
foreach ($json_parsed->linkset[0]->item as $item) {
$location = static::parseLocation($item);
$data = static::insertLink($location, $item->href, $item->title, $data);
$link_href = $item->href ?? '';
$link_title = $item->title ?? (string) $this->t('- Missing Link Title -');
$data = static::insertLink($location, $link_href, $link_title, $data);
}
// Convert the tree array into a tree of RemoteMenuLink objects.
$base_url = parse_url($url, PHP_URL_SCHEME) . '://' . parse_url($url, PHP_URL_HOST);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment