public function addressesAction()
    {
        $customer = $this->getCustomer();

        $typeCodes = BaseAddress::getTypesList();

        // This allows to specify the display order
        $addresses = [
            $typeCodes[AddressInterface::TYPE_DELIVERY] => [],
            $typeCodes[AddressInterface::TYPE_BILLING] => [],
            $typeCodes[AddressInterface::TYPE_CONTACT] => [],
        ];

        if (null === $customer) {
            // Customer not yet created, the user didn't order yet
            $customer = $this->getCustomerManager()->create();
            $customer->setUser($this->getUser());
            $this->getCustomerManager()->save($customer);
        } else {
            $custAddresses = $this->getAddressManager()->findBy(['customer' => $customer]);

            foreach ($custAddresses as $address) {
                $addresses[$address->getTypeCode()][] = $address;
            }
        }

        // Set redirection URL to be to the list of addresses
        $this->get('session')->set('sonata_address_redirect', $this->generateUrl('sonata_customer_addresses'));

        return $this->render('SonataCustomerBundle:Addresses:list.html.twig', [
                'addresses' => $addresses,
                'customer' => $customer,
                'breadcrumb_context' => 'customer_address',
            ]);
    }