Skip to content

Commit d410477

Browse files
committed
remove dependancy on container for hackzilla_ticket.templates
1 parent 8965076 commit d410477

4 files changed

Lines changed: 18 additions & 29 deletions

File tree

Controller/TicketController.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function indexAction(Request $request)
4545
);
4646

4747
return $this->render(
48-
$this->container->getParameter('hackzilla_ticket.templates.index'),
48+
$this->container->getParameter('hackzilla_ticket.templates')['index'],
4949
[
5050
'pagination' => $pagination,
5151
'ticketState' => $ticketState,
@@ -81,7 +81,7 @@ public function createAction(Request $request)
8181
}
8282

8383
return $this->render(
84-
$this->container->getParameter('hackzilla_ticket.templates.new'),
84+
$this->container->getParameter('hackzilla_ticket.templates')['new'],
8585
[
8686
'entity' => $ticket,
8787
'form' => $form->createView(),
@@ -100,7 +100,7 @@ public function newAction()
100100
$form = $this->createForm(TicketType::class, $entity);
101101

102102
return $this->render(
103-
$this->container->getParameter('hackzilla_ticket.templates.new'),
103+
$this->container->getParameter('hackzilla_ticket.templates')['new'],
104104
[
105105
'entity' => $entity,
106106
'form' => $form->createView(),
@@ -143,7 +143,7 @@ public function showAction($ticketId)
143143
$data['delete_form'] = $this->createDeleteForm($ticket->getId())->createView();
144144
}
145145

146-
return $this->render($this->container->getParameter('hackzilla_ticket.templates.show'), $data);
146+
return $this->render($this->container->getParameter('hackzilla_ticket.templates')['show'], $data);
147147
}
148148

149149
/**
@@ -190,7 +190,7 @@ public function replyAction(Request $request, $ticketId)
190190
$data['delete_form'] = $this->createDeleteForm($ticket->getId())->createView();
191191
}
192192

193-
return $this->render($this->container->getParameter('hackzilla_ticket.templates.show'), $data);
193+
return $this->render($this->container->getParameter('hackzilla_ticket.templates')['show'], $data);
194194
}
195195

196196
/**

DependencyInjection/HackzillaTicketExtension.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,7 @@ public function load(array $configs, ContainerBuilder $container)
3030
$container->setParameter('hackzilla_ticket.model.message.class', $config['message_class']);
3131

3232
$container->setParameter('hackzilla_ticket.features', $config['features']);
33-
34-
$container->setParameter('hackzilla_ticket.templates.index', $config['templates']['index']);
35-
$container->setParameter('hackzilla_ticket.templates.new', $config['templates']['new']);
36-
$container->setParameter('hackzilla_ticket.templates.prototype', $config['templates']['prototype']);
37-
$container->setParameter('hackzilla_ticket.templates.show', $config['templates']['show']);
38-
$container->setParameter('hackzilla_ticket.templates.show_attachment', $config['templates']['show_attachment']);
39-
$container->setParameter('hackzilla_ticket.templates.macros', $config['templates']['macros']);
33+
$container->setParameter('hackzilla_ticket.templates', $config['templates']);
4034
}
4135

4236
public static function bundleDirectory()

Resources/config/services.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ services:
5656
- '@hackzilla_ticket.features'
5757
tags:
5858
- { name: twig.extension }
59-
59+
6060
hackzilla_ticket.component.twig_extension.ticket_global:
6161
class: Hackzilla\Bundle\TicketBundle\TwigExtension\TicketGlobalExtension
6262
arguments:
63-
- '@service_container'
63+
- '%hackzilla_ticket.templates%'
6464
tags:
6565
- { name: twig.extension }
6666

TwigExtension/TicketGlobalExtension.php

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,16 @@
22

33
namespace Hackzilla\Bundle\TicketBundle\TwigExtension;
44

5-
use Symfony\Component\DependencyInjection\ContainerInterface;
6-
75
class TicketGlobalExtension extends \Twig_Extension implements \Twig_Extension_GlobalsInterface
86
{
9-
/**
10-
* @var \Symfony\Component\DependencyInjection\ContainerInterface
11-
*/
12-
protected $container;
7+
protected $templates = [];
138

149
/**
15-
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
10+
* @param array $templates
1611
*/
17-
public function __construct(ContainerInterface $container)
12+
public function __construct($templates)
1813
{
19-
$this->container = $container;
14+
$this->templates = $templates;
2015
}
2116

2217
/**
@@ -27,12 +22,12 @@ public function getGlobals()
2722
return [
2823
'hackzilla_ticket' => [
2924
'templates' => [
30-
'index' => $this->container->getParameter('hackzilla_ticket.templates.index'),
31-
'new' => $this->container->getParameter('hackzilla_ticket.templates.new'),
32-
'show' => $this->container->getParameter('hackzilla_ticket.templates.show'),
33-
'show_attachment' => $this->container->getParameter('hackzilla_ticket.templates.show_attachment'),
34-
'prototype' => $this->container->getParameter('hackzilla_ticket.templates.prototype'),
35-
'macros' => $this->container->getParameter('hackzilla_ticket.templates.macros'),
25+
'index' => $this->templates['index'],
26+
'new' => $this->templates['new'],
27+
'show' => $this->templates['show'],
28+
'show_attachment' => $this->templates['show_attachment'],
29+
'prototype' => $this->templates['prototype'],
30+
'macros' => $this->templates['macros'],
3631
],
3732
],
3833
];

0 commit comments

Comments
 (0)