public function renderAddress(\Twig_Environment $environment, $address, $showName = true, $showEdit = false, $context = null)
    {
        $requiredAddressKeys = ['firstname', 'lastname', 'address1', 'postcode', 'city', 'country_code'];

        if (!($address instanceof AddressInterface) && (!\is_array($address) || 0 !== \count(array_diff($requiredAddressKeys, array_keys($address))))) {
            throw new \RuntimeException(sprintf(
                'sonata_address_render needs an AddressInterface instance or an array with keys (%s)',
                implode(', ', $requiredAddressKeys)
            ));
        }

        if ($address instanceof AddressInterface) {
            $addressArray = [
                'id' => $showEdit ? $address->getId() : '',
                'name' => $showName ? $address->getName() : '',
                'address' => $address->getFullAddressHtml(),
            ];
        } else {
            if ($showEdit && !\array_key_exists('id', $address)) {
                throw new \RuntimeException(
                    "sonata_address_render needs 'id' key to be set to render the edit button"
                );
            }

            if ($showName && !\array_key_exists('name', $address)) {
                $address['name'] = '';
                $showName = false;
            }

            $addressArray = [
                'id' => $showEdit ? $address['id'] : '',
                'name' => $address['name'],
                'address' => BaseAddress::formatAddress($address, '<br/>'),
            ];
        }

        return $environment->render('SonataCustomerBundle:Addresses:_address.html.twig', [
                'address' => $addressArray,
                'showName' => $showName,
                'showEdit' => $showEdit,
                'context' => $context,
            ]
        );
    }