You are here

public function DevelCommands::token in Devel 4.x

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. 8.2 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 The tokens structured in a RowsOfFields object.

File

src/Commands/DevelCommands.php, line 224

Class

DevelCommands
Class DevelCommands.

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);
}