Skip to content

Latest commit

 

History

History
55 lines (42 loc) · 1.51 KB

File metadata and controls

55 lines (42 loc) · 1.51 KB

Usage

OroAddressBundle provides PHP/REST/SOAP API for address CRUD operations.

PHP API

<?php
    //Accessing address manager from controller
    /** @var  $addressManager \Oro\Bundle\AddressBundle\Entity\Manager\AddressManager */
    $addressManager = $this->get('oro_address.address.provider')->getStorage();

    //create empty address entity
    $address = $addressManager->createAddress();

    //process insert/update
    $this->get('oro_address.form.handler.address')->process($entity)

    //accessing address form service
    $this->get('oro_address.form.address')

REST API

    oro_api_get_addresstype   GET           /api/rest/{version}/addresstypes/{name}.{_format}
    oro_api_get_addresstypes  GET           /api/rest/{version}/addresstypes.{_format}

Address collection

Address collection may be added to form with next three steps

  1. Add field with type oro_address_collection to form
$builder->add(
    'addresses',
    'oro_address_collection',
    array(
        'required' => false,
        'type'     => 'oro_address'
    )
);
  1. Add AddressCollectionTypeSubscriber. AddressCollectionTypeSubscriber must be initialized with address collection field name and address class name.
$builder->addEventSubscriber(new AddressCollectionTypeSubscriber('addresses', $this->addressClass));
  1. In template add OroAddressBundle:Include:fields.html.twig to support address form field typed
{% form_theme form with ['OroAddressBundle:Include:fields.html.twig']}