Templating/Helper/Format/FormatHelper.php
public function renderValue($objectOrArray, $propertyPath, $format = null, array $options = [])
    {
        if (\is_array($objectOrArray) && $propertyPath && $propertyPath[0] !== '[') {
            $propertyPath = \sprintf('[%s]', $propertyPath);
        }

        if (null === $propertyPath) {
            $value = $objectOrArray;
        } else {
            try {
                $value = $this->accessor->getValue($objectOrArray, $propertyPath);
                $options['object'] = $objectOrArray;
            } catch (UnexpectedTypeException $e) {
                // the property path could not be reached
                $value = null;
            }
        }

        if (!empty($options['collection']) && true === $options['collection']) {
            unset($options['collection']);
            $propertyPath = null;
            if (!empty($options['propertyPath'])) {
                $propertyPath = $options['propertyPath'];
            }

            return $this->container->get('templating')->render('ImaticViewBundle:Field:collection.html.twig', [
                'value' => $value,
                'options' => $options,
                'format' => $format,
                'propertyPath' => $propertyPath,
            ]);
        }

        return $this->format($value, $format, $options);
    }
public function renderValue($objectOrArray, $propertyPath, $format = null, array $options = [])
    {
        if (\is_array($objectOrArray) && $propertyPath && $propertyPath[0] !== '[') {
            $propertyPath = \sprintf('[%s]', $propertyPath);
        }

        if (null === $propertyPath) {
            $value = $objectOrArray;
        } else {
            try {
                $value = $this->accessor->getValue($objectOrArray, $propertyPath);
                $options['object'] = $objectOrArray;
            } catch (UnexpectedTypeException $e) {
                // the property path could not be reached
                $value = null;
            }
        }

        if (!empty($options['collection']) && true === $options['collection']) {
            unset($options['collection']);
            $propertyPath = null;
            if (!empty($options['propertyPath'])) {
                $propertyPath = $options['propertyPath'];
            }

            return $this->container->get('templating')->render('ImaticViewBundle:Field:collection.html.twig', [
                'value' => $value,
                'options' => $options,
                'format' => $format,
                'propertyPath' => $propertyPath,
            ]);
        }

        return $this->format($value, $format, $options);
    }
@param array|object $objectOrArray
@param string|null  $propertyPath
@param string       $format
@param array        $options

@return string|null