This bundle integrates the [opentrans] (https://github.com/sveneisenschmidt/opentrans) library into Symfony2.
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(),
// ...
);
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
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();
$> vendor/bin/phpunit