Security update for Core, with self-updated composer
[yaffs-website] / vendor / drupal / console / src / Command / Shared / PermissionTrait.php
1 <?php
2
3 /**
4  * @file
5  * Contains Drupal\Console\Command\Shared\PermissionsTrait.
6  */
7
8 namespace Drupal\Console\Command\Shared;
9
10 trait PermissionTrait
11 {
12     /**
13      *
14      * @return mixed
15      */
16     public function permissionQuestion()
17     {
18         $permissions = [];
19         $boolOrNone = ['true','false','none'];
20         while (true) {
21             $permission = $this->getIo()->ask(
22                 $this->trans('commands.generate.permissions.questions.permission'),
23                 $this->trans('commands.generate.permissions.suggestions.access-content')
24             );
25             $title = $this->getIo()->ask(
26                 $this->trans('commands.generate.permissions.questions.title'),
27                 $this->trans('commands.generate.permissions.suggestions.access-content')
28             );
29             $description = $this->getIo()->ask(
30                 $this->trans('commands.generate.permissions.questions.description'),
31                 $this->trans('commands.generate.permissions.suggestions.allow-access-content')
32             );
33             $restrictAccess = $this->getIo()->choiceNoList(
34                 $this->trans('commands.generate.permissions.questions.restrict-access'),
35                 $boolOrNone,
36                 'none'
37             );
38
39             $permission = $this->stringConverter->camelCaseToLowerCase($permission);
40             $title = $this->stringConverter->anyCaseToUcFirst($title);
41
42             array_push(
43                 $permissions,
44                 [
45                     'permission' => $permission,
46                     'title' => $title,
47                     'description' => $description,
48                     'restrict_access' => $restrictAccess,
49                 ]
50             );
51
52             if (!$this->getIo()->confirm(
53                 $this->trans('commands.generate.permissions.questions.add'),
54                 true
55             )
56             ) {
57                 break;
58             }
59         }
60
61         return $permissions;
62     }
63 }