tiime/cross-industry-invoice

0.2.4 2023-11-24 09:22 UTC

This package is auto-updated.

Last update: 2024-09-24 11:05:15 UTC


README

如何在 Symfony 中添加此库?

下载此库

composer require tiime/cross-industry-invoice

如果您想使用位于 src/Resources/views/ 文件夹中的模板,您需要添加以下配置:

twig:
    # ...
    paths:
        '%kernel.project_dir%/vendor/tiime/cross-industry-invoice/src/Resources/views/': 'TiimeCII'

如果您想使用此库中的模板,还需要下载 twig/extra-bundle

composer require twig/extra-bundle

config/services.yaml 中添加以下配置:

Tiime\CrossIndustryInvoice\Renderer\TwigRenderer:
    arguments:
        $environment: '@twig'

Tiime\CrossIndustryInvoice\Renderer\CrossIndustryInvoiceRendererInterface: '@Tiime\CrossIndustryInvoice\Renderer\TwigRenderer'

如何使用它?

use Tiime\CrossIndustryInvoice\EN16931\CrossIndustryInvoice;
use Tiime\CrossIndustryInvoice\Renderer\CrossIndustryInvoiceRendererInterface;

class MyService
{
    public function __construct(private readonly CrossIndustryInvoiceRendererInterface $renderer)
    {
    }
    
    public function doSomething()
    {
        // Create CrossIndustryInvoice object with needed parameters
        $crossIndustryInvoice = new CrossIndustryInvoice(...);
        
        $this->renderer->render($crossIndustryInvoice, '@TiimeCII/en16931_invoice.html.twig')
    }
}