final class UserCommands extends DrushCommands (View source)

Traits

ProcessManagerAwareTrait
LoggerAwareTrait
IO
ConfigAwareTrait

Constants

REQ

OPT

EXIT_SUCCESS

EXIT_FAILURE

EXIT_FAILURE_WITH_CLARITY

INFORMATION

BLOCK

UNBLOCK

ROLE_ADD

ROLE_REMOVE

CREATE

CANCEL

PASSWORD

INF_LABELS

INF_DEFAULT_FIELDS

Properties

protected CommandData|null $commandData from  DrushCommands

Methods

bool
startBrowser(string|null $uri = null, int $sleep = 0, int|null $port = null, string|bool $browser = false)

Starts a background browser/tab for the current site or a specified URL.

static bool
programExists($program)

No description

static string
getEditor(string|null $editor = null)

No description

getConfig()

Replaces same method in ConfigAwareTrait in order to provide a DrushConfig as return type. Helps with IDE completion.

__construct(DateFormatterInterface $dateFormatter)

No description

SymfonyStyle
io()

Override Robo's IO function with our custom style.

DrushLoggerManager|null
logger()

Returns a logger object.

void
printFile(string $file)

Print the contents of a file.

preHook(CommandData $commandData)

Persist commandData for use in primary command callback. Used by 'topic' commands.

printFileTopic(CommandData $commandData)

Print the contents of a file. The path comes from the @topic annotation.

HandlerStack
getStack()

Get a Guzzle handler stack that uses the Drush logger.

static UserCommands
create(ContainerInterface $container)

No description

RowsOfFields
information(string $names = '', $options = ['format' => 'table', 'uid' => self::REQ, 'mail' => self::REQ])

Print information about the specified user(s).

renderRolesCell($key, $cellData, FormatterOptions $options)

No description

void
block(string $names = '', $options = ['uid' => self::REQ, 'mail' => self::REQ])

Block the specified user(s).

void
unblock(string $names = '', $options = ['uid' => self::REQ, 'mail' => self::REQ])

Unblock the specified user(s).

void
addRole(string $role, string $names = '', $options = ['uid' => self::REQ, 'mail' => self::REQ])

Add a role to the specified user accounts.

void
removeRole(string $role, string $names = '', $options = ['uid' => self::REQ, 'mail' => self::REQ])

Remove a role from the specified user accounts.

CommandError
createUser(string $name, $options = ['format' => 'table', 'password' => self::REQ, 'mail' => self::REQ])

Create a user account.

void
createValidate(CommandData $commandData)

Assure that provided username is available.

void
cancel(string $names = '', $options = ['delete-content' => false, 'reassign-content' => false, 'uid' => self::REQ, 'mail' => self::REQ])

Block or delete user account(s) with the specified name(s).

void
password(string $name, string $password)

Set the password for the user account with the specified name.

array
infoArray($account)

A flatter and simpler array presentation of a Drupal $user object.

array
getAccounts(string $names = '', array $options = [])

Get accounts from name variables or uid & mail options.

void
roleComplete(CompletionInput $input, CompletionSuggestions $suggestions)

No description

Details

bool startBrowser(string|null $uri = null, int $sleep = 0, int|null $port = null, string|bool $browser = false)

Starts a background browser/tab for the current site or a specified URL.

Uses a non-blocking Process call, so Drush execution will continue.

Parameters

string|null $uri

Optional URI or site path to open in browser. If omitted, or if a site path is specified, the current site home page uri will be prepended if the site's hostname resolves.

int $sleep
int|null $port
string|bool $browser

Return Value

bool

if browser was opened. FALSE if browser was disabled by the user or a default browser could not be found.

static bool programExists($program)

No description

Parameters

$program

Return Value

bool

static string getEditor(string|null $editor = null)

No description

Parameters

string|null $editor

Return Value

string

DrushConfig getConfig()

Replaces same method in ConfigAwareTrait in order to provide a DrushConfig as return type. Helps with IDE completion.

__construct(DateFormatterInterface $dateFormatter)

No description

Parameters

DateFormatterInterface $dateFormatter

protected SymfonyStyle io()

Override Robo's IO function with our custom style.

Return Value

SymfonyStyle

protected DrushLoggerManager|null logger()

Returns a logger object.

Return Value

DrushLoggerManager|null

protected void printFile(string $file)

Print the contents of a file.

Parameters

string $file

Full path to a file.

Return Value

void

preHook(CommandData $commandData)

Persist commandData for use in primary command callback. Used by 'topic' commands.

Parameters

CommandData $commandData

protected printFileTopic(CommandData $commandData)

Print the contents of a file. The path comes from the @topic annotation.

Parameters

CommandData $commandData

Full path to a file.

protected HandlerStack getStack()

Get a Guzzle handler stack that uses the Drush logger.

static UserCommands create(ContainerInterface $container)

No description

Parameters

ContainerInterface $container

Return Value

UserCommands

RowsOfFields information(string $names = '', $options = ['format' => 'table', 'uid' => self::REQ, 'mail' => self::REQ])

Print information about the specified user(s).

Parameters

string $names
$options

Return Value

RowsOfFields

renderRolesCell($key, $cellData, FormatterOptions $options)

No description

Parameters

$key
$cellData
FormatterOptions $options

void block(string $names = '', $options = ['uid' => self::REQ, 'mail' => self::REQ])

Block the specified user(s).

Parameters

string $names
$options

Return Value

void

void unblock(string $names = '', $options = ['uid' => self::REQ, 'mail' => self::REQ])

Unblock the specified user(s).

Parameters

string $names
$options

Return Value

void

void addRole(string $role, string $names = '', $options = ['uid' => self::REQ, 'mail' => self::REQ])

Add a role to the specified user accounts.

Parameters

string $role
string $names
$options

Return Value

void

void removeRole(string $role, string $names = '', $options = ['uid' => self::REQ, 'mail' => self::REQ])

Remove a role from the specified user accounts.

Parameters

string $role
string $names
$options

Return Value

void

CommandError createUser(string $name, $options = ['format' => 'table', 'password' => self::REQ, 'mail' => self::REQ])

Create a user account.

Parameters

string $name
$options

Return Value

CommandError

void createValidate(CommandData $commandData)

Assure that provided username is available.

Parameters

CommandData $commandData

Return Value

void

void cancel(string $names = '', $options = ['delete-content' => false, 'reassign-content' => false, 'uid' => self::REQ, 'mail' => self::REQ])

Block or delete user account(s) with the specified name(s).

  • Existing content may be deleted or reassigned to the Anonymous user. See options.
  • By default only nodes are deleted or reassigned. Custom entity types need own code to support cancellation. See https://www.drupal.org/project/drupal/issues/3043725 for updates.

Parameters

string $names
$options

Return Value

void

void password(string $name, string $password)

Set the password for the user account with the specified name.

Parameters

string $name
string $password

Return Value

void

array infoArray($account)

A flatter and simpler array presentation of a Drupal $user object.

Parameters

$account

Return Value

array

protected array getAccounts(string $names = '', array $options = [])

Get accounts from name variables or uid & mail options.

Parameters

string $names
array $options

A array of loaded accounts.

Return Value

array

Exceptions

Exception

void roleComplete(CompletionInput $input, CompletionSuggestions $suggestions)

No description

Parameters

CompletionInput $input
CompletionSuggestions $suggestions

Return Value

void