ViolationPath
class ViolationPath implements IteratorAggregate, PropertyPathInterface
Methods
__construct(string $violationPath) Creates a new violation path from a string. | ||
string | __toString() Returns the string representation of the property path. | |
int | getLength() Returns the length of the property path, i.e. the number of elements. | |
PropertyPath | getParent() Returns the parent property path. | |
array | getElements() Returns the elements of the property path as array. | |
string | getElement(int $index) Returns the element at the given index in the property path. | |
bool | isProperty(int $index) Returns whether the element at the given index is a property. | |
bool | isIndex(int $index) Returns whether the element at the given index is an array index. | |
bool | mapsForm(int $index) Returns whether an element maps directly to a form. | |
ViolationPathIterator | getIterator() Returns a new iterator for this path. |
Details
__construct(string $violationPath)
Creates a new violation path from a string.
Parameters
string | $violationPath | The property path of a {@link \Symfony\Component\Validator\ConstraintViolation} object |
string __toString()
Returns the string representation of the property path.
Return Value
string | The path as string |
int getLength()
Returns the length of the property path, i.e. the number of elements.
Return Value
int | The path length |
PropertyPath getParent()
Returns the parent property path.
The parent property path is the one that contains the same items as this one except for the last one.
If this property path only contains one item, null is returned.
Return Value
PropertyPath | The parent path or null |
array getElements()
Returns the elements of the property path as array.
Return Value
array | An array of property/index names |
string getElement(int $index)
Returns the element at the given index in the property path.
Parameters
int | $index | The index key |
Return Value
string | A property or index name |
Exceptions
OutOfBoundsException | If the offset is invalid |
bool isProperty(int $index)
Returns whether the element at the given index is a property.
Parameters
int | $index | The index in the property path |
Return Value
bool | Whether the element at this index is a property |
Exceptions
OutOfBoundsException | If the offset is invalid |
bool isIndex(int $index)
Returns whether the element at the given index is an array index.
Parameters
int | $index | The index in the property path |
Return Value
bool | Whether the element at this index is an array index |
Exceptions
OutOfBoundsException | If the offset is invalid |
bool mapsForm(int $index)
Returns whether an element maps directly to a form.
Consider the following violation path:
children[address].children[office].data.street
In this example, "address" and "office" map to forms, while "street does not.
Parameters
int | $index | The element index |
Return Value
bool | Whether the element maps to a form |
Exceptions
OutOfBoundsException | if the offset is invalid |
ViolationPathIterator getIterator()
Returns a new iterator for this path.
Return Value
ViolationPathIterator |
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/4.0/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationPath.html