Security update for Core, with self-updated composer
[yaffs-website] / vendor / drupal / console / src / Command / Shared / MenuTrait.php
1 <?php
2
3 /**
4  * @file
5  * Contains Drupal\Console\Command\Shared\MenuTrait.
6  */
7
8 namespace Drupal\Console\Command\Shared;
9
10 use Symfony\Component\Yaml\Parser;
11
12 /**
13  * Class MenuTrait
14  *
15  * @package Drupal\Console\Command
16  */
17 trait MenuTrait
18 {
19     /**
20      * @param string                                 $className The form class name
21      * @return string
22      * @throws \Exception
23      */
24     public function menuQuestion($className)
25     {
26         if ($this->getIo()->confirm(
27             $this->trans('commands.generate.form.options.menu-link-gen'),
28             true
29         )
30         ) {
31             // now we need to ask them where to gen the form
32             // get the route
33             $menu_options = [
34                 'menu_link_gen' => true,
35             ];
36             $menu_link_title = $this->getIo()->ask(
37                 $menu_link_title = $this->trans('commands.generate.form.options.menu-link-title'),
38                 $className
39             );
40             $menuLinkFile = sprintf(
41                 '%s/core/modules/system/system.links.menu.yml',
42                 $this->appRoot
43             );
44
45             $parser = new Parser();
46             $menuLinkContent = $parser->parse(file_get_contents($menuLinkFile));
47
48
49             $menu_parent = $this->getIo()->choiceNoList(
50                 $menu_parent = $this->trans('commands.generate.form.options.menu-parent'),
51                 array_keys($menuLinkContent),
52                 'system.admin_config_system'
53             );
54
55             $menu_link_desc = $this->getIo()->ask(
56                 $menu_link_desc = $this->trans('commands.generate.form.options.menu-link-desc'),
57                 $menu_link_desc = $this->trans('commands.generate.form.suggestions.description-for-menu')
58             );
59             $menu_options['menu_link_title'] = $menu_link_title;
60             $menu_options['menu_parent'] = $menu_parent;
61             $menu_options['menu_link_desc'] = $menu_link_desc;
62             return $menu_options;
63         }
64     }
65 }