function LinkCollection::validKey

Same name in other branches
  1. 9 core/modules/jsonapi/src/JsonApiResource/LinkCollection.php \Drupal\jsonapi\JsonApiResource\LinkCollection::validKey()
  2. 8.9.x core/modules/jsonapi/src/JsonApiResource/LinkCollection.php \Drupal\jsonapi\JsonApiResource\LinkCollection::validKey()
  3. 11.x core/modules/jsonapi/src/JsonApiResource/LinkCollection.php \Drupal\jsonapi\JsonApiResource\LinkCollection::validKey()

Ensures that a link key is valid.

Parameters

string $key: A key name.

Return value

bool TRUE if the key is valid, FALSE otherwise.

2 calls to LinkCollection::validKey()
LinkCollection::withLink in core/modules/jsonapi/src/JsonApiResource/LinkCollection.php
Gets a new LinkCollection with the given link inserted.
LinkCollection::__construct in core/modules/jsonapi/src/JsonApiResource/LinkCollection.php
LinkCollection constructor.

File

core/modules/jsonapi/src/JsonApiResource/LinkCollection.php, line 197

Class

LinkCollection
Contains a set of JSON:API Link objects.

Namespace

Drupal\jsonapi\JsonApiResource

Code

protected static function validKey($key) {
    return is_string($key) && !is_numeric($key) && !str_contains($key, ':');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.