You are here

public function WebformEditorialController::schema in Webform 8.5

Returns webform schema.

Return value

array A renderable array containing webform entity scheme.

1 string reference to 'WebformEditorialController::schema'
webform_editorial.routing.yml in modules/webform_editorial/webform_editorial.routing.yml
modules/webform_editorial/webform_editorial.routing.yml

File

modules/webform_editorial/src/Controller/WebformEditorialController.php, line 366

Class

WebformEditorialController
Provides route responses for webform editorial.

Namespace

Drupal\webform_editorial\Controller

Code

public function schema() {

  // Header.
  $header = [
    [
      'data' => $this
        ->t('Name'),
      'width' => '20%',
    ],
    [
      'data' => $this
        ->t('Type'),
      'width' => '20%',
    ],
    [
      'data' => $this
        ->t('Description'),
      'width' => '60%',
    ],
  ];

  // Rows.
  $rows = [];

  /** @var \Drupal\Core\Field\BaseFieldDefinition[] $base_fields */
  $base_fields = $this->entityFieldManager
    ->getBaseFieldDefinitions('webform_submission');
  foreach ($base_fields as $field_name => $base_field) {
    $rows[] = [
      'data' => [
        [
          'data' => $field_name,
        ],
        [
          'data' => $base_field
            ->getType(),
        ],
        [
          'data' => $base_field
            ->getDescription(),
        ],
      ],
    ];
  }
  $build = $this
    ->buildTable('Webform Submission', $header, $rows);
  return $this
    ->response($build);
}