You are here

public function ConfigPagesLoaderService::getFieldView in Config Pages 8.3

Same name and namespace in other branches
  1. 8.2 src/ConfigPagesLoaderService.php \Drupal\config_pages\ConfigPagesLoaderService::getFieldView()

Get render array of CP.

Parameters

string|ConfigPages $type: Config page object or type name.

string $field_name: Field name you like to get.

string $view_mode: View mode name.

Return value

array|null Render array of CP in specified view mode.

Overrides ConfigPagesLoaderServiceInterface::getFieldView

File

src/ConfigPagesLoaderService.php, line 110

Class

ConfigPagesLoaderService
Class ConfigPagesLoaderService.

Namespace

Drupal\config_pages

Code

public function getFieldView($type, $field_name, $view_mode = 'full') {

  // Exit if empty config page.
  $config_page = is_object($type) ? $type : $this
    ->load($type);
  if (empty($config_page) || !$config_page
    ->hasField($field_name)) {
    return [];
  }
  return $config_page
    ->get($field_name)
    ->view($view_mode);
}