-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathGenerateUsers.php
43 lines (35 loc) · 1.12 KB
/
GenerateUsers.php
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
<?php
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Plugins\VisitorGenerator\Commands;
use Piwik\Access;
use Piwik\Plugin\ConsoleCommand;
use Piwik\Plugins\VisitorGenerator\Generator\Users;
class GenerateUsers extends ConsoleCommand
{
protected function configure()
{
$this->setName('visitorgenerator:generate-users');
$this->setDescription('Generates many users. This command is intended for developers.');
$this->addRequiredValueOption('limit', null, 'Defines how many users should be generated', 10);
}
/**
* @return int
*/
protected function doExecute(): int
{
$input = $this->getInput();
$limit = $input->getOption('limit');
$userLogins = Access::doAsSuperUser(function () use ($limit) {
$websiteGenerator = new Users();
return $websiteGenerator->generate((int) $limit);
});
$this->writeSuccessMessage(array(count($userLogins) . ' Users generated'));
return self::SUCCESS;
}
}