You are here

public function PublicFieldInfoBase::addCategory in RESTful 7.2

Add categories to the field info.

Parameters

string $category_name: The name of the categories. By default RESTful suports 'info', 'form_element' and 'data'.

array $section_info: The structured array with the section information.

Overrides PublicFieldInfoInterface::addCategory

2 calls to PublicFieldInfoBase::addCategory()
PublicFieldInfoBase::addSectionDefaults in src/Plugin/resource/Field/PublicFieldInfo/PublicFieldInfoBase.php
Merges default data in a section if it's not populated.
PublicFieldInfoBase::__construct in src/Plugin/resource/Field/PublicFieldInfo/PublicFieldInfoBase.php
PublicFieldInfoBase constructor.

File

src/Plugin/resource/Field/PublicFieldInfo/PublicFieldInfoBase.php, line 81
Contains \Drupal\restful\Plugin\resource\Field\PublicFieldInfo\PublicFieldInfoBase.

Class

PublicFieldInfoBase

Namespace

Drupal\restful\Plugin\resource\Field\PublicFieldInfo

Code

public function addCategory($category_name, array $section_info) {
  try {
    $this
      ->validate($category_name, $section_info);

    // Process the section info adding defaults if needed.
    $this->categories[$category_name] = $this
      ->process($category_name, $section_info);
  } catch (ServerConfigurationException $e) {

    // If there are validation errors do not add the section.
  }
}