You are here

public function ConfigPagesCommands::pagesGetFieldValue in Config Pages 8.3

Same name and namespace in other branches
  1. 8.2 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

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

$field_name: The name of field

null $context:

File

src/Commands/ConfigPagesCommands.php, line 81

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