Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
menu_parser_php
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
menu_parser_php
Commits
c065d673
Commit
c065d673
authored
1 year ago
by
Alec Smrekar
Browse files
Options
Downloads
Patches
Plain Diff
Avoid exception on empty link href/title
parent
1e5a9a8e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/RemoteMenuParser.php
+6
-1
6 additions, 1 deletion
src/RemoteMenuParser.php
with
6 additions
and
1 deletion
src/RemoteMenuParser.php
+
6
−
1
View file @
c065d673
...
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment