diff --git a/src/RemoteMenuParser.php b/src/RemoteMenuParser.php index 8fabe7fa664a48831c1afc1a455c9a2a975ddcca..21fd68f8e284607f25a08d7aebd8c4695e4b073e 100644 --- a/src/RemoteMenuParser.php +++ b/src/RemoteMenuParser.php @@ -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);