-
- // Symfony 2.5+
- if ($this->context instanceof ExecutionContextInterface) {
- $variables['value'] = $value;
- $variables['this'] = $this->context->getObject();
- } elseif (null === $this->context->getPropertyName()) {
- $variables['value'] = $value;
- $variables['this'] = $value;
- } else {
- $root = $this->context->getRoot();
- $variables['value'] = $value;
-
- if (is_object($root)) {
- // Extract the object that the property belongs to from the object
- // graph
- $path = new PropertyPath($this->context->getPropertyPath());
- $parentPath = $path->getParent();
- $variables['this'] = $parentPath ? $this->getPropertyAccessor()->getValue($root, $parentPath) : $root;
- } else {
- $variables['this'] = null;
- }
- }