You are here

protected function FormatterJsonApi::buildIncludePath in RESTful 7.2

Build the dot notation path for an array of parents.

Remove numeric parents since those only indicate that the field was multivalue, not a parent: articles[related][1][tags][2][name] turns into 'articles.related.tags.name'.

Parameters

array $parents: The nested parents.

string $public_field_name: The field name.

Return value

string The path.

2 calls to FormatterJsonApi::buildIncludePath()
FormatterJsonApi::needsIncluding in src/Plugin/formatter/FormatterJsonApi.php
Checks if a resource field needs to be embedded in the response.
FormatterJsonApi::renormalize in src/Plugin/formatter/FormatterJsonApi.php
Move the embedded resources to the included key.

File

src/Plugin/formatter/FormatterJsonApi.php, line 548
Contains \Drupal\restful\Plugin\formatter\FormatterJsonApi.

Class

FormatterJsonApi
Class FormatterJsonApi @package Drupal\restful\Plugin\formatter

Namespace

Drupal\restful\Plugin\formatter

Code

protected function buildIncludePath(array $parents, $public_field_name = NULL) {
  $array_path = $parents;
  if ($public_field_name) {
    array_push($array_path, $public_field_name);
  }
  $include_path = implode('.', array_filter($array_path, function ($item) {
    return !is_numeric($item);
  }));
  return $include_path;
}