You are here

public function ConfigPagesCommands::pagesGetFieldValue in Config Pages 8.2

Same name and namespace in other branches
  1. 8.3 src/Commands/ConfigPagesCommands.php \Drupal\config_pages\Commands\ConfigPagesCommands::pagesGetFieldValue()

Get a value for the field of Config Pages.

@validate-module-enabled config_pages

@command config:pages-get-field-value @aliases cpgfv,config-pages-get-field-value

Parameters

string $bundle: The type of config page "/admin/structure/config_pages/types".

string $field_name: The name of field.

null $context: Context.

File

src/Commands/ConfigPagesCommands.php, line 85

Class

ConfigPagesCommands
A Drush command file.

Namespace

Drupal\config_pages\Commands

Code

public function pagesGetFieldValue($bundle, $field_name, $context = NULL) {
  try {
    $config_page = config_pages_config($bundle, $context);
    if (!empty($config_page)) {
      $this
        ->output()
        ->writeln($config_page
        ->get($field_name)->value);
    }
  } catch (\Exception $e) {
    $this
      ->logger()
      ->error($e
      ->getMessage());
  }
}