You are here

public function DevelCommands::token in Devel 8.2

Same name and namespace in other branches
  1. 8.3 src/Commands/DevelCommands.php \Drupal\devel\Commands\DevelCommands::token()
  2. 8 src/Commands/DevelCommands.php \Drupal\devel\Commands\DevelCommands::token()
  3. 4.x src/Commands/DevelCommands.php \Drupal\devel\Commands\DevelCommands::token()

List available tokens.

@command devel:token @aliases token,devel-token @field-labels group: Group token: Token name: Name @default-fields group,token,name

Return value

\Consolidation\OutputFormatters\StructuredData\RowsOfFields

File

src/Commands/DevelCommands.php, line 178

Class

DevelCommands
For commands that are parts of modules, Drush expects to find commandfiles in __MODULE__/src/Commands, and the namespace is Drupal/__MODULE__/Commands.

Namespace

Drupal\devel\Commands

Code

public function token($options = [
  'format' => 'table',
]) {
  $all = $this
    ->getToken()
    ->getInfo();
  foreach ($all['tokens'] as $group => $tokens) {
    foreach ($tokens as $key => $token) {
      $rows[] = [
        'group' => $group,
        'token' => $key,
        'name' => $token['name'],
      ];
    }
  }
  return new RowsOfFields($rows);
}