Conditions | 3 |
Paths | 3 |
Total Lines | 21 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
36 | public function addLibrary(GetResponseEvent $event): void |
||
37 | { |
||
38 | if (!$event->isMasterRequest()) { |
||
39 | return; |
||
40 | } |
||
41 | |||
42 | // Only add the library on 'real' page loads, not AJAX requests like add to cart |
||
43 | if ($event->getRequest()->isXmlHttpRequest()) { |
||
44 | return; |
||
45 | } |
||
46 | |||
47 | $this->tagBag->addTag( |
||
48 | (new ScriptTag('var StrandsTrack = window.StrandsTrack || [];')) |
||
49 | ->setSection(TagInterface::SECTION_BODY_END) |
||
50 | ->setPriority(100) |
||
51 | ); |
||
52 | $this->tagBag->addTag( |
||
53 | (new TwigTag('@SetonoSyliusStrandsPlugin/Tag/library.html.twig', ['api_id' => $this->apiId])) |
||
54 | ->setSection(TagInterface::SECTION_BODY_END) |
||
55 | ->setName(Tags::TAG_LIBRARY) |
||
56 | ->setPriority(-100) |
||
57 | ); |
||
60 |