function TypedData::getPropertyPath

Same name in other branches
  1. 9 core/lib/Drupal/Core/TypedData/TypedData.php \Drupal\Core\TypedData\TypedData::getPropertyPath()
  2. 8.9.x core/lib/Drupal/Core/TypedData/TypedData.php \Drupal\Core\TypedData\TypedData::getPropertyPath()
  3. 10 core/lib/Drupal/Core/TypedData/TypedData.php \Drupal\Core\TypedData\TypedData::getPropertyPath()

Overrides TypedDataInterface::getPropertyPath

File

core/lib/Drupal/Core/TypedData/TypedData.php, line 173

Class

TypedData
The abstract base class for typed data.

Namespace

Drupal\Core\TypedData

Code

public function getPropertyPath() {
    if (isset($this->parent)) {
        // The property path of this data object is the parent's path appended
        // by this object's name.
        $prefix = $this->parent
            ->getPropertyPath();
        // Variables in double quotes used to leverage fast string concatenation.
        // In PHP 7+ concatenation with variable inside string is the fastest.
        // @see https://blog.blackfire.io/php-7-performance-improvements-encapsed-strings-optimization.html
        // This is being done because the code can run in the critical path.
        return $prefix !== '' ? "{$prefix}.{$this->name}" : $this->name;
    }
    elseif (isset($this->name)) {
        return $this->name;
    }
    return '';
}

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