padam87/address-bundle

Symfony2 AddressBundle

Installs: 13 176

Dependents: 0

Suggesters: 0

Security: 0

Stars: 10

Watchers: 2

Forks: 6

Open Issues: 2

Type:symfony-bundle

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

This package is auto-updated.

Last update: 2024-12-17 09:47:26 UTC


README

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

1, Installation

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