You are here

public function ExecutionContext::getPropertyPath in Zircon Profile 8

Same name in this branch
  1. 8 vendor/symfony/validator/ExecutionContext.php \Symfony\Component\Validator\ExecutionContext::getPropertyPath()
  2. 8 vendor/symfony/validator/Context/ExecutionContext.php \Symfony\Component\Validator\Context\ExecutionContext::getPropertyPath()
  3. 8 core/lib/Drupal/Core/TypedData/Validation/ExecutionContext.php \Drupal\Core\TypedData\Validation\ExecutionContext::getPropertyPath()
Same name and namespace in other branches
  1. 8.0 vendor/symfony/validator/ExecutionContext.php \Symfony\Component\Validator\ExecutionContext::getPropertyPath()

Returns the property path to the value that the validator is currently validating.

For example, take the following object graph:

<pre> (Person)---($address: Address)---($street: string) </pre>

When the <tt>Person</tt> instance is passed to the validator, the property path is initially empty. When the <tt>$address</tt> property of that person is validated, the property path is "address". When the <tt>$street</tt> property of the related <tt>Address</tt> instance is validated, the property path is "address.street".

Properties of objects are prefixed with a dot in the property path. Indices of arrays or objects implementing the {@link \ArrayAccess} interface are enclosed in brackets. For example, if the property in the previous example is <tt>$addresses</tt> and contains an array of <tt>Address</tt> instance, the property path generated for the <tt>$street</tt> property of one of these addresses is for example "addresses[0].street".

Parameters

string $subPath Optional. The suffix appended to the current: property path.

Return value

string The current property path. The result may be an empty string if the validator is currently validating the root value of the validation graph.

Overrides ExecutionContextInterface::getPropertyPath

3 calls to ExecutionContext::getPropertyPath()
ExecutionContext::addViolationAt in vendor/symfony/validator/ExecutionContext.php
Adds a violation at the validation graph node with the given property path relative to the current property path.
ExecutionContext::validate in vendor/symfony/validator/ExecutionContext.php
Validates the given value within the scope of the current validation.
ExecutionContext::validateValue in vendor/symfony/validator/ExecutionContext.php
Validates a value against a constraint.

File

vendor/symfony/validator/ExecutionContext.php, line 159

Class

ExecutionContext
Default implementation of {@link ExecutionContextInterface}.

Namespace

Symfony\Component\Validator

Code

public function getPropertyPath($subPath = '') {
  if ('' != $subPath && '' !== $this->propertyPath && '[' !== $subPath[0]) {
    return $this->propertyPath . '.' . $subPath;
  }
  return $this->propertyPath . $subPath;
}