-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathProfilesListCommand.php
More file actions
64 lines (59 loc) · 2.06 KB
/
ProfilesListCommand.php
File metadata and controls
64 lines (59 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to contact@h-hennes.fr so we can send you a copy immediately.
*
* @author Hennes Hervé <contact@h-hennes.fr>
* @copyright since 2016 Hennes Hervé
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* https://github.com/nenes25/prestashop_console
* https://www.h-hennes.fr/blog/
*/
namespace PrestashopConsole\Command\Admin;
use Context;
use Exception;
use PrestashopConsole\Command\PrestashopConsoleAbstractCmd as Command;
use Profile;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class ProfilesListCommand extends Command
{
protected function configure(): void
{
$this
->setName('admin:profiles:list')
->setDescription('List admin profiles')
->setHelp('List all admin user profiles');
}
public function execute(InputInterface $input, OutputInterface $output): int
{
try {
$idLang = Context::getContext()->language->id;
$profiles = Profile::getProfiles($idLang);
if ($profiles) {
$table = new Table($output);
$table->setHeaders(['id_profile', 'name']);
foreach ($profiles as $profile) {
$table->addRow(
[
$profile['id_profile'],
$profile['name'],
]
);
}
$table->render();
}
return self::RESPONSE_SUCCESS;
} catch (Exception $e) {
return self::RESPONSE_ERROR;
}
}
}