You are here

public function App::get in Apigee Edge 8

Gets a field item list.

Parameters

string $field_name: The name of the field to get; e.g., 'title' or 'name'.

Return value

\Drupal\Core\Field\FieldItemListInterface The field item list, containing the field items.

Throws

\InvalidArgumentException If an invalid field name is given.

Overrides AttributesAwareFieldableEdgeEntityBase::get

File

src/Entity/App.php, line 389

Class

App
Base class for App Drupal entities.

Namespace

Drupal\apigee_edge\Entity

Code

public function get($field_name) {
  $value = parent::get($field_name);

  // Make sure that returned callback url field values are actually valid
  // URLs. Apigee Edge allows to set anything as callbackUrl value but
  // Drupal can only accept valid URIs.
  if ($field_name === 'callbackUrl') {
    if (!$value
      ->isEmpty()) {
      foreach ($value
        ->getValue() as $id => $item) {
        try {
          Url::fromUri($item['value']);
        } catch (\Exception $exception) {
          $value
            ->removeItem($id);
        }
      }
    }
  }
  return $value;
}