se / opentrans-bundle
This bundle integrates the opentrans library into Symfony2. Allows to create OpenTRANS compatible documents from PHP.
Installs: 182
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 3
Open Issues: 0
Type:bundle
Requires
- php: >=5.3.3
- se/opentrans: ~0.1
Requires (Dev)
- phpunit/phpunit: 3.7.*
- symfony/symfony: 2.3.*
This package is not auto-updated.
Last update: 2024-12-12 04:18:25 UTC
README
This bundle integrates the [opentrans] (https://github.com/sveneisenschmidt/opentrans) library into Symfony2.
Dev branch is master branch.
Table of Contents
Installation
The recommended way to install is through Composer.
{ "require": { "se/opentrans-bundle": "dev-master" } }
Add the bundle to your AppKernel.php file:
// in AppKernel::registerBundles() $bundles = array( // ... new SE\Bundle\OpenTransBundle\SEOpenTransBundle(), // ... );
Configuration
You can declare default documents in your app configuration. (i.e. app/config/config.yml)
se_open_trans: documents: my_default_order_document: type: order document: header: control_info: generator_info: "My Order Document" my_default_order_document_2: type: order document: header: control_info: generator_info: "My Order Document 2" order_info: custom_key: custom_var my_shop_id: Magento_1702
Usage
Your configured document builder is available as a member in se.opentrans.document_builder_manager
service.
Retrieve it by calling $manager->getDocumentBuilder($documentName)
.
$manager = $container->get('se.opentrans.document_builder_manager'); $builder = $manager->getDocumentBuilder('my_default_order_document'); $document = $builder->getDocument();
The document builder is created as a service aswell. So instead calling the document builder manager you can
directly load the document builder from the container. The name is consisting of the base key se.opentrans.document_builder.
plus the se_open_trans.documents
key from your configuration. (i.e. my_default_order_document
)
$builder = $container->get('se.opentrans.document_builder.my_default_order_document'); $document = $builder->getDocument();
Run tests
$> vendor/bin/phpunit