为了在Symfony中创建PDF文件,我使用TCPDF类和WhiteOctoberTCPDFBundle。都通过作曲家安装。使用WhiteOctoberBundle创建扩展TCPDF的类
我需要通过扩展TCPDF类来创建自定义页眉和页脚,如TCPDF documentation中所述。
但我唯一的工作解决方案是直接在供应商中扩展TCPDF类,然后在供应商/ whiteoctober/tcpdf-bundle/DependencyInjection/Configuration.php中的getConfigTreeBuilder()方法内的WhiteOctoberBundle中将默认的MYPDF类设置为默认类。
所以我的configuration.php文件看起来像这样:
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('white_october_tcpdf');
$rootNode
->children()
->scalarNode('file')->defaultValue('%kernel.root_dir%/../vendor/tecnick.com/tcpdf/tcpdf.php')->end()
->scalarNode('class')->defaultValue('MYPDF')->end()
->end();
$this->addTCPDFConfig($rootNode);
return $treeBuilder;
}
的问题是,直接在供应商扩展TCPDF类是不好的做法,它会导致该MYPDF类TCPDF捆绑的每次更新过程中消失。我应该在哪里放置MYPDF类,以便它可以保持访问WhiteOctoberBundle,同时它不会被放置在供应商文件夹内?这里:-)这