padam87/address-bundle

Symfony2 AddressBundle

v2.0.0 2016-11-14 20:07 UTC

README

Build Status Coverage Status Scrutinizer Quality Score SensioLabsInsight Latest Stable Version Total Downloads Latest Unstable Version License

1.1 Composer

composer require padam87/address-bundle

1.2 AppKernel

// app/AppKernel.php
public function registerBundles()
{
    return array(
        // ...
        new Padam87\AddressBundle\Padam87AddressBundle(),
    );
}

2, Usage

Use the traits and embeddables with your schema.

2.1 Formatter

$formatted = $this->get("padam87.address.formatter")->format($address);

Flags

use Padam87\AddressBundle\Service\FormatterService;

//...

$formatted = $this->get("padam87.address.formatter")->format($address, FormatterService::FLAG_NOBR);

Available flags

  • FLAG_NOBR No linebreak will be added
  • FLAG_HTML Outputs the address in html format

Extend / override templates

You can override or extend the language-specific formats. Just create the appropriate template under app\Resources\Padam87AddressBundle\views

example: app\Resources\Padam87AddressBundle\views\US.twig contributing: Create a PR with your own country's format :)

2.2 Twig extension

{{ address|address()|raw }}

This will output the formatted address, with the FLAG_HTML added by default