Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
menu_export
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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
menu_export
Merge requests
!15
Resolve
#3323102
"Drush command 1.x"
Code
Review changes
Check out branch
Open in Workspace
Download
Patches
Plain diff
Expand sidebar
Open
Resolve
#3323102
"Drush command 1.x"
issue/menu_export-3323102:3323102-drush-command-1.x
into
8.x-1.x
Overview
0
Commits
3
Pipelines
0
Changes
4
Open
Resolve #3323102 "Drush command 1.x"
mortona2k
requested to merge
issue/menu_export-3323102:3323102-drush-command-1.x
into
8.x-1.x
Jul 14, 2024
Overview
0
Commits
3
Pipelines
0
Changes
4
Closes
#3323102
0
0
Merge request reports
Compare
8.x-1.x
version 1
1a0166db
Jul 14, 2024
8.x-1.x (HEAD)
and
latest version
latest version
b340c318
3 commits,
Jul 14, 2024
version 1
1a0166db
2 commits,
Jul 14, 2024
4 files
+
96
−
13
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
4
src/Commands/MenuExportDrushCommands.php
0 → 100644
+
54
−
0
View file @ 21864d39
Edit in single-file editor
Open in Web IDE
<?php
namespace
Drupal\menu_export\Commands
;
use
Drush\Commands\DrushCommands
;
use
Drupal\menu_export
\Form\MenuExportForm
;
use
Drupal\menu_export
\Form\MenuImportForm
;
/**
* Drush commands for importing / exporting menu items from / to config.
*
* @package Drupal\menu_export\Commands
*/
class
MenuExportDrushCommands
extends
DrushCommands
{
/**
* Drush command for exporting menu items to config using default configuration.
*
* @command menu_export:export
* @aliases menu-export-export menu_export-export
* @usage menu_export:export
*/
public
function
export
()
{
$form
=
new
MenuExportForm
(
\Drupal
::
configFactory
());
if
(
$form
->
exportMenus
())
{
$this
->
output
()
->
writeln
(
t
(
'Menu(s) exported successfully'
));
}
else
{
throw
new
\Exception
(
t
(
'Menu export did NOT work.'
));
}
}
/**
* Drush command for importing menu items to config using default config.
*
* @command menu_export:import
* @aliases menu-export-import menu_export-import
* @usage menu_export:import
*/
public
function
import
()
{
$form
=
new
MenuImportForm
(
\Drupal
::
configFactory
());
$invalidMenus
=
$form
->
importMenus
();
if
(
count
(
$invalidMenus
)
==
0
)
{
$this
->
output
()
->
writeln
(
t
(
'Menu(s) imported successfully'
));
}
else
{
throw
new
\Exception
(
t
(
'Menu(s) @menus not found'
,[
'@menus'
=>
implode
(
','
,
$invalidMenus
)
]));
}
}
}
Loading